validate_crs {arcgisutils} | R Documentation |
Validate CRS object
Description
Takes a representation of a CRS and ensures that it is a valid one. The CRS
is validated using sf::st_crs()
if it cannot be validated, a null CRS is returned.
Usage
validate_crs(crs, arg = rlang::caller_arg(crs), call = rlang::caller_env())
Arguments
crs |
a representation of a coordinate reference system. |
arg |
An argument name in the current function. |
call |
The execution environment of a currently running
function, e.g. You only need to supply Can also be For more information about error calls, see Including function calls in error messages. |
Details
See sf::st_crs()
for more details on valid representations.
Value
Returns a list of length 1 with an element named spatialReference
which is itself
a named list.
If the provided CRS returns a valid well-known ID (WKID) spatialReference
contains
a named element called wkid
which is the integer value of the WKID. If the WKID
is not known but the CRS returned is a valid well-known text representation the wkid
field
is NA
and another field wkt
contains the valid wkt.
Examples
# using epsg code integer or string representation
validate_crs(3857)
validate_crs("EPSG:4326")
# using a custom proj4 string
proj4string <- "+proj=longlat +datum=WGS84 +no_defs"
crs <- validate_crs(proj4string)
# using wkt2 (from above result)
crs <- validate_crs(crs$spatialReference$wkt)