reproject {plotKML}R Documentation

Methods to reproject maps to a referent coordinate system (WGS84)

Description

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).

Usage

## 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)

Arguments

obj

Spatial* or Raster* object

CRS

object of class "CRS"; proj4 string

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."bilinear"

...

arguments evaluated in the context of function projectRaster from the raster package

Details

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().

Warning

obj needs to have a proper proj4 string (CRS), otherwise reproject will not run.

Author(s)

Pierre Roudier, Tomislav Hengl and Dylan Beaudette

References

See Also

paths, projectRaster, spTransform, CRS-class

Examples

## 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)

[Package plotKML version 0.5-8 Index]