Skip to contents

A class agnostic function to return the projection of a spatial object or source. returned projection uses wkt format.

Usage

get_proj(x, ...)

# S3 method for SpatRaster
get_proj(x, ...)

# S3 method for SpatVector
get_proj(x, ...)

# S3 method for sf
get_proj(x, ...)

# S3 method for sfc
get_proj(x, ...)

# S3 method for stars
get_proj(x, ...)

# S3 method for stars_proxy
get_proj(x, ...)

# S3 method for ezgrid
get_proj(x, ...)

# S3 method for character
get_proj(x, ...)

Arguments

x

A spatial object, file path or source

...

Not used

Value

A character - WKT projection string.

See also

Other spatial helpers (class agnostic): get_dim(), get_ext(), get_source()

Examples

f <- system.file("ex/elev.tif", package="terra") 
get_proj(f)
#> [1] "GEOGCRS[\"WGS 84\",\n    DATUM[\"World Geodetic System 1984\",\n        ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n            LENGTHUNIT[\"metre\",1]]],\n    PRIMEM[\"Greenwich\",0,\n        ANGLEUNIT[\"degree\",0.0174532925199433]],\n    CS[ellipsoidal,2],\n        AXIS[\"geodetic latitude (Lat)\",north,\n            ORDER[1],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n        AXIS[\"geodetic longitude (Lon)\",east,\n            ORDER[2],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n    ID[\"EPSG\",4326]]"
get_proj(terra::rast(f))
#> [1] "GEOGCRS[\"WGS 84\",\n    DATUM[\"World Geodetic System 1984\",\n        ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n            LENGTHUNIT[\"metre\",1]]],\n    PRIMEM[\"Greenwich\",0,\n        ANGLEUNIT[\"degree\",0.0174532925199433]],\n    CS[ellipsoidal,2],\n        AXIS[\"geodetic latitude (Lat)\",north,\n            ORDER[1],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n        AXIS[\"geodetic longitude (Lon)\",east,\n            ORDER[2],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n    ID[\"EPSG\",4326]]"
f2 <- system.file("ex/lux.shp", package="terra") 
get_proj(f2)
#> [1] "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\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"