Change the coordinate reference system ("project") of a SpatVector or SpatRaster. For a SpatRaster, you have more control with the warp
method.
# S4 method for SpatVector
project(x, crs, ...)
# S4 method for SpatRaster
project(x, crs, method="bilinear", filename="", overwrite=FALSE, wopt=list(), ...)
SpatVector
character. Description of output coordinate reference system in PROJ.4 notation
character. Method used to compute values. "bilinear"
for bilinear interpolation, or "ngb"
for "nearest neighbor"
character. Output filename. Optional
logical. If TRUE
, filename
is overwritten
list. Options for writing files as in writeRaster
additional arguments. None implemented
SpatVector or SpatRaster
# 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