Learn R Programming

plotKML (version 0.2-4)

reproject: 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

reproject(obj, ...)

Arguments

obj
Spatial* or Raster* object
...
arguments evaluated in the context of function projectRaster from the raster package

Warning

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

Details

In the case of raster and/or gridded maps, by selecting program = "FWTools" gdalwarp functionality will be initiated (otherwise it tries to reproject via the package raster). This requires that http://fwtools.maptools.org{FWTools} are installed and located from R via paths(). FWTools includes OpenEV, GDAL, MapServer, PROJ.4 and OGDI, and can be installed on Windows and Unix-type operating systems.

References

  • Raster package (http://CRAN.R-project.org/package=raster)
  • FWTools (http://fwtools.maptools.org)

See Also

paths, raster::projectRaster, rgdal::spTransform, rgdal::CRS-class

Examples

Run this code
# example with vector data
data(eberg)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
eberg.geo <- reproject(eberg)
# 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)
# much faster when using FWTools:
eberg_grid_ll2 <- reproject(eberg_grid25, program = "FWTools")
# optional: compare processing times:
system.time(eberg_grid_ll <- reproject(eberg_grid25[1]))
system.time(eberg_grid_ll2 <- reproject(eberg_grid25[1], program="FWTools"))

Run the code above in your browser using DataLab