Skip to content
Prev 10117 / 29559 Next

Re projecting rasters (projectRaster)

Dear Bart,

You have data NE of the Caribbean, and project these to the whole
world. The below illustrates what goes wrong:

library(raster)
library(maptools)
data(wrld_simpl)

# create example raster
h<-1000000
a<-raster(matrix(1:100, nrow=10),xmn=-h, xmx=h, ymn=-h,ymx=h,
crs="+proj=aeqd +lon_0=-52.577189655172 +lat_0=21.5126379310345")
a[] <- 1:ncell(a)

# project to longlat
ageo <- projectRaster(a, raster())
plot(ageo)
plot(wrld_simpl, add=T)
# Oops a copy of the values in Australia.


This happens because the coordinates of those locations transform to
the same coordinates in the Azimuthal Equidistant projection (going
"through the world";  projectRaster uses the reverse of the projection
you ask it to do, i.e. it transforms coordinates from the output
raster to those of the input raster).

I had not considered that someone would do this type of transfer (from
a small part to the entire world) but there is nothing wrong with this
and I will fix projectRaster for these cases (which should also make
the function much faster too for these cases).

Robert
On Fri, Nov 26, 2010 at 7:49 AM, bart <bart at njn.nl> wrote: