Skip to content

Commit 6e13be9

Browse files
committed
closes #2415
1 parent 4ba1f3c commit 6e13be9

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ S3method(st_snap,sfg)
314314
S3method(st_sym_difference,sf)
315315
S3method(st_sym_difference,sfc)
316316
S3method(st_sym_difference,sfg)
317+
S3method(st_transform,bbox)
317318
S3method(st_transform,sf)
318319
S3method(st_transform,sfc)
319320
S3method(st_transform,sfg)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# version 1.0-17
22

3+
* add `st_transform()` method for `bbox` objects; this uses OGRCoordinateTransformation::TransformBounds(), densifying first and antemeridian proof; #2415
4+
35
* `st_filter.sf()` correctly scopes `x` and `y` arguments using !! operator; #2416
46

57
* `[.sfc` and `[<-.sfc` use matrix/array type subsetting for `sfc` objects that have a `dim` attribute

R/transform.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ st_transform.sfg = function(x, crs = st_crs(x), ...) {
165165
structure(st_transform(x, crs, ...)[[1]], crs = crs)
166166
}
167167

168+
#' @name st_transform
169+
#' @export
170+
#' @param densify integer, number of points for discretizing lines between bounding box corner points; see Details
171+
#' @details the method for `bbox` objects densifies lines for geographic coordinates along Cartesian lines, not great circle arcs
172+
st_transform.bbox = function(x, crs, ..., densify = 21) {
173+
st_bbox(CPL_transform_bounds(x, st_crs(crs), densify), crs = crs)
174+
}
175+
168176
#' @name st_transform
169177
#' @export
170178
st_wrap_dateline = function(x, options, quiet) UseMethod("st_wrap_dateline")

man/st_transform.Rd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/gdal.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,12 @@ Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_
698698
ret[1] = ymin;
699699
ret[2] = xmax;
700700
ret[3] = ymax;
701+
Rcpp::CharacterVector names(4);
702+
names(0) = "xmin";
703+
names(1) = "ymin";
704+
names(2) = "xmax";
705+
names(3) = "ymax";
706+
ret.attr("names") = names;
701707
ct->DestroyCT(ct);
702708
dst->Release();
703709
src->Release();

0 commit comments

Comments
 (0)