g_transform | R Documentation |
g_transform()
will transform the coordinates of a geometry from their
current spatial reference system to a new target spatial reference system.
Normally this means reprojecting the vectors, but it could include datum
shifts, and changes of units.
g_transform(
geom,
srs_from,
srs_to,
wrap_date_line = FALSE,
date_line_offset = 10L,
traditional_gis_order = TRUE,
as_wkb = TRUE,
as_iso = FALSE,
byte_order = "LSB",
quiet = FALSE
)
geom |
Either a raw vector of WKB or list of raw vectors, or a character vector containing one or more WKT strings. |
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
|
wrap_date_line |
Logical value, |
date_line_offset |
Integer longitude gap in degree. Defaults to |
traditional_gis_order |
Logical value, |
as_wkb |
Logical value, |
as_iso |
Logical value, |
byte_order |
Character string specifying the byte order when output is
WKB. One of |
quiet |
Logical value, |
A geometry as WKB raw vector or WKT string, or a list/character vector of
geometries as WKB/WKT with length equal to the number of input geometries.
NA
is returned with a warning if WKB input cannot be converted into an
OGR geometry object, or if an error occurs in the call to the underlying
OGR API.
This function uses the OGR_GeomTransformer_Create()
and
OGR_GeomTransformer_Transform()
functions in the GDAL API: "This is an
enhanced version of OGR_G_Transform()
. When reprojecting geometries from
a Polar Stereographic projection or a projection naturally crossing the
antimeridian (like UTM Zone 60) to a geographic CRS, it will cut geometries
along the antimeridian. So a LineString
might be returned as a
MultiLineString
."
The wrap_date_line = TRUE
option might be specified for circumstances to
correct geometries that incorrectly go from a longitude on a side of the
antimeridian to the other side, e.g., LINESTRING (-179 0,179 0)
will be
transformed to MULTILINESTRING ((-179 0,-180 0),(180 0,179 0))
. For that
use case, srs_to
might be the same as srs_from
.
bbox_transform()
, transform_bounds()
pt <- "POINT (-114.0 47.0)"
g_transform(pt, "WGS84", "EPSG:5070", as_wkb = FALSE)
# correct geometries that incorrectly go from a longitude on a side of the
# antimeridian to the other side
geom <- "LINESTRING (-179 0,179 0)"
g_transform(geom, "WGS84", "WGS84", wrap_date_line = TRUE, as_wkb = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.