Skip to content

Commit

Permalink
bb_shrink to preserve crs
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Nov 29, 2024
1 parent 2a6d62e commit 14ce3e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/proxy.R
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,14 @@ merge.stars_proxy = function(x, y, ..., name = "attributes") {

# shrink bbox with e * width in each direction
bb_shrink = function(bb, e) {
stopifnot(inherits(bb, "bbox"))
dx = diff(bb[c("xmin", "xmax")])
dy = diff(bb[c("ymin", "ymax")])
st_bbox(setNames(c(bb["xmin"] + e * dx,
bb["ymin"] + e * dy,
bb["xmax"] - e * dx,
bb["ymax"] - e * dy), c("xmin", "ymin", "xmax", "ymax")))
bb["ymax"] - e * dy), c("xmin", "ymin", "xmax", "ymax")),
crs = st_crs(bb))
}

#' @name st_crop
Expand Down

0 comments on commit 14ce3e1

Please sign in to comment.