Return the value of a parameter (the name or the unit) present in the WKT of the given CRS.
projpar(x, par, abort = FALSE) projname(x, abort = FALSE)
x | The CRS to be named (any st_crs2 input is accepted). |
---|---|
par | Character corresponding to the parameter name (it can be one among "name" and "unit" - case insensitive). |
abort | logical: if TRUE, the function aborts in case an invalid CRS is passed; if FALSE (default), the function returns NA, and a warning is shown. |
A character with the content of the parameter, and an
attribute crs
with the input projection checked using
sf::st_crs()
.
The old function, which was searching for a generic parameter
parsing the WKT, was deprecated: now projpar()
only accepts par = "name"
and par = "unit"
, and projname()
is an alias for projpar(..., par = "name")
.
License: GPL 3.0
# \donttest{ projpar(4326, "name")#> [1] "WGS 84" #> attr(,"crs") #> Coordinate Reference System: #> User input: EPSG:4326 #> wkt: #> GEOGCS["WGS 84", #> DATUM["WGS_1984", #> SPHEROID["WGS 84",6378137,298.257223563, #> AUTHORITY["EPSG","7030"]], #> AUTHORITY["EPSG","6326"]], #> PRIMEM["Greenwich",0, #> AUTHORITY["EPSG","8901"]], #> UNIT["degree",0.0174532925199433, #> AUTHORITY["EPSG","9122"]], #> AUTHORITY["EPSG","4326"]]projpar(4326, "unit")#> [1] "degree" #> attr(,"crs") #> Coordinate Reference System: #> User input: EPSG:4326 #> wkt: #> GEOGCS["WGS 84", #> DATUM["WGS_1984", #> SPHEROID["WGS 84",6378137,298.257223563, #> AUTHORITY["EPSG","7030"]], #> AUTHORITY["EPSG","6326"]], #> PRIMEM["Greenwich",0, #> AUTHORITY["EPSG","8901"]], #> UNIT["degree",0.0174532925199433, #> AUTHORITY["EPSG","9122"]], #> AUTHORITY["EPSG","4326"]]# } # \donttest{ projname(4326)#> [1] "WGS 84" #> attr(,"crs") #> Coordinate Reference System: #> User input: EPSG:4326 #> wkt: #> GEOGCS["WGS 84", #> DATUM["WGS_1984", #> SPHEROID["WGS 84",6378137,298.257223563, #> AUTHORITY["EPSG","7030"]], #> AUTHORITY["EPSG","6326"]], #> PRIMEM["Greenwich",0, #> AUTHORITY["EPSG","8901"]], #> UNIT["degree",0.0174532925199433, #> AUTHORITY["EPSG","9122"]], #> AUTHORITY["EPSG","4326"]]# }