terra (version 0.3-7)

project: Change the coordinate reference system

Description

Change the coordinate reference system ("project") of a SpatVector or SpatRaster. For a SpatRaster, you have more control with the warp method.

Usage

# S4 method for SpatVector
project(x, crs, ...)
# S4 method for SpatRaster
project(x, crs, method="bilinear", filename="", overwrite=FALSE, wopt=list(), ...)

Arguments

x

SpatVector

crs

character. Description of output coordinate reference system in PROJ.4 notation

method

character. Method used to compute values. "bilinear" for bilinear interpolation, or "ngb" for "nearest neighbor"

filename

character. Output filename. Optional

overwrite

logical. If TRUE, filename is overwritten

wopt

list. Options for writing files as in writeRaster

...

additional arguments. None implemented

Value

SpatVector or SpatRaster

See Also

warp

Examples

Run this code
# NOT RUN {
f <- system.file("exdata/lux.shp", package="terra")
v <- vect(f)
crs <- "+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84"
p <- project(v, crs)
p

a <- rast(ncol=40, nrow=40, xmin=-110, xmax=-90, ymin=40, ymax=60, crs="+proj=longlat +datum=WGS84")
values(a) = 1:ncell(a)
crs="+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +datum=WGS84"
b <- project(a, crs)
# }

Run the code above in your browser using DataLab