reproject | R Documentation |
This wrapper function reprojects any vector or raster spatial data to some referent coordinate system (by default: geographic coordinates on the World Geodetic System of 1984 / WGS84 datum).
## S4 method for signature 'SpatialPoints' reproject(obj, CRS, ...) ## S4 method for signature 'SpatialPolygons' reproject(obj, CRS, ...) ## S4 method for signature 'SpatialLines' reproject(obj, CRS, ...) ## S4 method for signature 'RasterLayer' reproject(obj, CRS, program = "raster", tmp.file = TRUE, NAflag, show.output.on.console = FALSE, method, ...) ## S4 method for signature 'SpatialGridDataFrame' reproject(obj, CRS, tmp.file = TRUE, program = "raster", NAflag, show.output.on.console = FALSE, ...) ## S4 method for signature 'SpatialPixelsDataFrame' reproject(obj, CRS, tmp.file = TRUE, program = "raster", NAflag, show.output.on.console = FALSE, ...) ## S4 method for signature 'RasterBrick' reproject(obj, CRS) ## S4 method for signature 'RasterStack' reproject(obj, CRS)
obj |
Spatial* or Raster* object |
CRS |
object of class |
program |
reprojection engine; either raster package or GDAL |
tmp.file |
logical; specifies whether to create a temporary file or not |
NAflag |
character; missing value flag |
show.output.on.console |
logical; specifies whether to print the progress |
method |
character; resampling method e.g. |
... |
arguments evaluated in the context of function |
In the case of raster and/or gridded maps, by selecting program = "GDAL"
gdalwarp
functionality will be initiated (otherwise it tries to reproject via the package raster). This requires that GDAL are installed and located from R via paths()
.
obj
needs to have a proper proj4 string (CRS), otherwise reproject
will not run.
Pierre Roudier, Tomislav Hengl and Dylan Beaudette
Raster package (https://CRAN.R-project.org/package=raster)
GDAL (https://gdal.org)
paths, projectRaster, spTransform, CRS-class
## example with vector data: data(eberg) library(sp) library(rgdal) coordinates(eberg) <- ~X+Y proj4string(eberg) <- CRS("+init=epsg:31467") eberg.geo <- reproject(eberg) ## Not run: ## example with raster data: data(eberg_grid25) gridded(eberg_grid25) <- ~x+y proj4string(eberg_grid25) <- CRS("+init=epsg:31467") ## reproject to geographical coords (can take few minutes!): eberg_grid_ll <- reproject(eberg_grid25[1]) ## much faster when using GDAL: eberg_grid_ll2 <- reproject(eberg_grid25[1], program = "GDAL") ## optional: compare processing times: system.time(eberg_grid_ll <- reproject(eberg_grid25[1])) system.time(eberg_grid_ll2 <- reproject(eberg_grid25[1], program="GDAL")) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.