bbox_transform | R Documentation |
bbox_transform()
is a convenience function to transform the coordinates
of a boundary from their current spatial reference system to a new target
spatial reference system.
bbox_transform(bbox, srs_from, srs_to, use_transform_bounds = TRUE)
bbox |
Numeric vector of length four containing a bounding box (xmin, ymin, xmax, ymax) to transform. |
srs_from |
Character string specifying the spatial reference system
for |
srs_to |
Character string specifying the output spatial reference
system. May be in WKT format or any of the formats supported by
|
use_transform_bounds |
Logical value, |
With use_transform_bounds = TRUE
(the default) this function returns:
# requires GDAL >= 3.4 transform_bounds(bbox, srs_from, srs_to)
See Details for transform_bounds()
for cases where the bounds crossed the
antimeridian.
With use_transform_bounds = FALSE
, this function returns:
bbox_to_wkt(bbox) |> g_transform(srs_from, srs_to) |> bbox_from_wkt()
See the Note for g_transform()
for cases where the bounds crossed the
antimeridian.
Numeric vector of length four containing a transformed bounding box (xmin, ymin, xmax, ymax).
bbox_from_wkt()
, g_transform()
, transform_bounds()
bb <- c(-1405880.72, -1371213.76, 5405880.72, 5371213.76)
# the default assumes GDAL >= 3.4
if (gdal_version_num() >= gdal_compute_version(3, 4, 0)) {
bb_wgs84 <- bbox_transform(bb, "EPSG:32661", "EPSG:4326")
} else {
bb_wgs84 <- bbox_transform(bb, "EPSG:32661", "EPSG:4326",
use_transform_bounds = FALSE)
}
print(bb_wgs84)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.