Title: | Extract Coordinate System Metadata |
---|---|
Description: | Obtain coordinate system metadata from various data formats. There are functions to extract a 'CRS' (coordinate reference system, <https://en.wikipedia.org/wiki/Spatial_reference_system>) in 'EPSG' (European Petroleum Survey Group, <http://www.epsg.org/>), 'PROJ4' <https://proj.org/>, or 'WKT2' (Well-Known Text 2, <http://docs.opengeospatial.org/is/12-063r5/12-063r5.html>) forms. This is purely for getting simple metadata from in-memory formats, please use other tools for out of memory data sources. |
Authors: | Michael Sumner [aut, cre] |
Maintainer: | Michael Sumner <[email protected]> |
License: | GPL-3 |
Version: | 0.3.0 |
Built: | 2024-11-28 02:52:28 UTC |
Source: | https://github.com/hypertidy/crsmeta |
Obtain the 'EPSG' string from an object, if it has one. Supported inputs include sf.
crs_epsg(x, ...)
crs_epsg(x, ...)
x |
object with 'EPSG' value |
... |
ignored |
integer (or NA)
crs_wkt2()
crs_proj()
crs_input()
crs_epsg(sfx) x <- sfx attr(x$geom, "crs")$epsg <- NA ## oh no we lost it crs_epsg(x) crs_epsg(sfx_new) ## NA, doesn't exist now
crs_epsg(sfx) x <- sfx attr(x$geom, "crs")$epsg <- NA ## oh no we lost it crs_epsg(x) crs_epsg(sfx_new) ## NA, doesn't exist now
Obtain the 'input' string from an object, if it has one. Supported inputs include sf (>= 0.8-1 - probably).
crs_input(x, ...)
crs_input(x, ...)
x |
object with 'input' value |
... |
ignored |
character (or NA)
Note that the 'input' value could be almost anything, there is a
huge variety of inputs that can work such as 4326
, projstrings,
WKT2 strings, EPSG declarations 'EPSG:4326'
, or common strings like
'WGS84'
or 'NAD27'
.
Strings like '+init=epsg:4326'
have been deprecated but still
can work, so beware.
crs_wkt2()
crs_proj()
crs_epsg()
crs_input(sfx) ## doesn't have one crs_input(sfx_new) ## a proj4string
crs_input(sfx) ## doesn't have one crs_input(sfx_new) ## a proj4string
Obtain the 'PROJ4' string from an object, if it has one. Supported inputs include raster, sf, sp, and silicate.
crs_proj(x, ...)
crs_proj(x, ...)
x |
object with 'PROJ4' string |
... |
ignored |
character string (or NA
)
crs_epsg()
crs_wkt2()
crs_input()
crs_proj(sfx) crs_proj(sfx$geom) crs_proj(sfx_new) ## NA
crs_proj(sfx) crs_proj(sfx$geom) crs_proj(sfx_new) ## NA
Obtain the 'WKT2' string from an object, if it has one. Supported inputs include sp and sf.
crs_wkt2(x, ...) crs_wkt(x, ...)
crs_wkt2(x, ...) crs_wkt(x, ...)
x |
object with 'WKT2' string |
... |
ignored |
The functions crs_wkt()
and crs_wkt2()
are aliased, they do the same
thing.
character string (or NA
)
For WKT2 only, PROJ6 and beyond
crs_epsg()
crs_proj()
crs_wkt()
crs_input()
crs_wkt2(sfx) # NA crs_wkt2(sfx$geom) # NA crs_wkt2(sfx_new) crs_wkt2(sfx_new$geom)
crs_wkt2(sfx) # NA crs_wkt2(sfx$geom) # NA crs_wkt2(sfx_new) crs_wkt2(sfx_new$geom)
A copy of the 'minimal_mesh' data set from the silicate package, with coordinate reference system information added.
sfx
is the old-style PROJ.4 and EPSG code CRS (prior to sf 0.8-1).
sfx_new
is the new-style WKT2, with user input.
do not use this data in real situations, or as exemplary of the 'sf' format. It was created purely to add examples to this package.
## three equivalent representations, of increasing richness crs_epsg(sfx) crs_proj(sfx) crs_wkt2(sfx) ## did not exist in earlier sf ## new style crs_epsg(sfx_new) ## NA! crs_proj(sfx_new) ## NA! crs_input(sfx_new) crs_wkt(sfx_new)
## three equivalent representations, of increasing richness crs_epsg(sfx) crs_proj(sfx) crs_wkt2(sfx) ## did not exist in earlier sf ## new style crs_epsg(sfx_new) ## NA! crs_proj(sfx_new) ## NA! crs_input(sfx_new) crs_wkt(sfx_new)