Convert spatial reference from EPSG code to OGC Well Known Text
Source:R/RcppExports.R
epsg_to_wkt.Rd
epsg_to_wkt()
exports the spatial reference for an EPSG code to
WKT format.
Arguments
- epsg
Integer EPSG code.
- pretty
Logical.
TRUE
to return a nicely formatted WKT string for display to a person.FALSE
for a regular WKT string (the default).
Details
As of GDAL 3.0, the default format for WKT export is OGC WKT 1.
The WKT version can be overridden by using the OSR_WKT_FORMAT
configuration option (see set_config_option()
).
Valid values are one of: SFSQL, WKT1_SIMPLE, WKT1, WKT1_GDAL,
WKT1_ESRI, WKT2_2015, WKT2_2018, WKT2, DEFAULT.
If SFSQL, a WKT1 string without AXIS, TOWGS84, AUTHORITY or
EXTENSION node is returned. If WKT1_SIMPLE, a WKT1 string without
AXIS, AUTHORITY or EXTENSION node is returned. WKT1 is an alias of
WKT1_GDAL. WKT2 will default to the latest revision implemented
(currently WKT2_2018). WKT2_2019 can be used as an alias of
WKT2_2018 since GDAL 3.2
Examples
epsg_to_wkt(5070)
#> [1] "PROJCS[\"NAD83 / Conus Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4269\"]],PROJECTION[\"Albers_Conic_Equal_Area\"],PARAMETER[\"latitude_of_center\",23],PARAMETER[\"longitude_of_center\",-96],PARAMETER[\"standard_parallel_1\",29.5],PARAMETER[\"standard_parallel_2\",45.5],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"5070\"]]"
writeLines(epsg_to_wkt(5070, pretty=TRUE))
#> PROJCS["NAD83 / Conus Albers",
#> GEOGCS["NAD83",
#> DATUM["North_American_Datum_1983",
#> SPHEROID["GRS 1980",6378137,298.257222101,
#> AUTHORITY["EPSG","7019"]],
#> AUTHORITY["EPSG","6269"]],
#> PRIMEM["Greenwich",0,
#> AUTHORITY["EPSG","8901"]],
#> UNIT["degree",0.0174532925199433,
#> AUTHORITY["EPSG","9122"]],
#> AUTHORITY["EPSG","4269"]],
#> PROJECTION["Albers_Conic_Equal_Area"],
#> PARAMETER["latitude_of_center",23],
#> PARAMETER["longitude_of_center",-96],
#> PARAMETER["standard_parallel_1",29.5],
#> PARAMETER["standard_parallel_2",45.5],
#> PARAMETER["false_easting",0],
#> PARAMETER["false_northing",0],
#> UNIT["metre",1,
#> AUTHORITY["EPSG","9001"]],
#> AXIS["Easting",EAST],
#> AXIS["Northing",NORTH],
#> AUTHORITY["EPSG","5070"]]
set_config_option("OSR_WKT_FORMAT", "WKT2")
writeLines(epsg_to_wkt(5070, pretty=TRUE))
#> PROJCRS["NAD83 / Conus Albers",
#> BASEGEOGCRS["NAD83",
#> DATUM["North American Datum 1983",
#> ELLIPSOID["GRS 1980",6378137,298.257222101,
#> LENGTHUNIT["metre",1]]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433]],
#> ID["EPSG",4269]],
#> CONVERSION["Conus Albers",
#> METHOD["Albers Equal Area",
#> ID["EPSG",9822]],
#> PARAMETER["Latitude of false origin",23,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8821]],
#> PARAMETER["Longitude of false origin",-96,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8822]],
#> PARAMETER["Latitude of 1st standard parallel",29.5,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8823]],
#> PARAMETER["Latitude of 2nd standard parallel",45.5,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8824]],
#> PARAMETER["Easting at false origin",0,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8826]],
#> PARAMETER["Northing at false origin",0,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8827]]],
#> CS[Cartesian,2],
#> AXIS["easting (X)",east,
#> ORDER[1],
#> LENGTHUNIT["metre",1]],
#> AXIS["northing (Y)",north,
#> ORDER[2],
#> LENGTHUNIT["metre",1]],
#> USAGE[
#> SCOPE["Data analysis and small scale data presentation for contiguous lower 48 states."],
#> AREA["United States (USA) - CONUS onshore - Alabama; Arizona; Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia; Idaho; Illinois; Indiana; Iowa; Kansas; Kentucky; Louisiana; Maine; Maryland; Massachusetts; Michigan; Minnesota; Mississippi; Missouri; Montana; Nebraska; Nevada; New Hampshire; New Jersey; New Mexico; New York; North Carolina; North Dakota; Ohio; Oklahoma; Oregon; Pennsylvania; Rhode Island; South Carolina; South Dakota; Tennessee; Texas; Utah; Vermont; Virginia; Washington; West Virginia; Wisconsin; Wyoming."],
#> BBOX[24.41,-124.79,49.38,-66.91]],
#> ID["EPSG",5070]]
set_config_option("OSR_WKT_FORMAT", "")