Get the coordinate reference system of a spatial object.
getCRS(x, ...) # S4 method for ANY getCRS(x) # S4 method for geom getCRS(x) # S4 method for Spatial getCRS(x) # S4 method for sf getCRS(x) # S4 method for Raster getCRS(x) # S4 method for SpatRaster getCRS(x)
| x | the object from which to extract the coordinate reference system. |
|---|---|
| ... | other arguments. |
The coordinate reference system of x given as proj4string.
Other getters:
getCols(),
getExtent(),
getFeatures(),
getGroups(),
getHistory(),
getLayers(),
getNames(),
getPoints(),
getRes(),
getRows(),
getType(),
getWindow()
obj <- gtGeoms$line %>% setCRS("+proj=longlat +datum=WGS84 +no_defs") getCRS(obj) #> [1] "+proj=longlat +datum=WGS84 +no_defs" gc_sp(obj) %>% getCRS() #> [1] "+proj=longlat +datum=WGS84 +no_defs" gc_sf(obj) %>% getCRS() #> [1] "+proj=longlat +datum=WGS84 +no_defs" gc_raster(gtGeoms$grid$categorical) %>% getCRS() #> [1] NA gc_terra(gtGeoms$grid$categorical) %>% getCRS() #> [1] "+proj=longlat +datum=WGS84 +no_defs" getCRS(x = matrix(0, 3, 5)) #> [1] NA getCRS(x = gtGeoms$grid$continuous) #> [1] NA library(sf) #> Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1 nc_sf <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE) getCRS(nc_sf) #> [1] "+proj=longlat +datum=NAD27 +no_defs"