Learn R Programming

terra (version 0.8-5)

crs: Get or set a coordinate reference system

Description

Get or set the coordinate reference system (CRS), also referred to as a "projection" of a SpatRaster or SpatVector object.

Setting a new CRS does not change the data itself, it just changes the label. So you should only set the CRS of a dataset (if it does not come with one) to what it *is*, not to what you would *like it to be*. See project to *transform* spatial from one CRS to another.

Usage

# S4 method for SpatRaster
crs(x)

# S4 method for SpatVector crs(x)

# S4 method for SpatRaster crs(x, ...)<-value

# S4 method for SpatVector crs(x, ...)<-value

Arguments

x

SpatRaster or SpatVector

value

character string describing a coordinate reference system. This can be in a WKT format, as a EPSG code, or a PROJ.4 "+" format (but see Note)

...

additional arguments (none implemented)

Value

character or modified SpatRaster/Vector

Examples

Run this code
# NOT RUN {
r <- rast()
crs(r)
crs(r) <- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +ellps=WGS84"
crs(r)

# You can also use epsg codes
crs(r)  <- "epsg:25831"
# }

Run the code above in your browser using DataLab