[R-sig-Geo] Problem with extent of output raster from crop() function in raster package

Robert Hijmans r.hijmans at gmail.com
Mon Jun 27 17:34:42 CEST 2011


> I'm currently having some problems getting the crop() function in the
raster 
> package to work properly, and cannot for the life of me figure out what's 
> going on. 
> Essentially, I'm trying to crop a larger raster (raster1) to match one
> with 
> a smaller extent (raster2), which is entirely contained in the first
> raster. 
> The projections seem to match and the resolution is the same. 
> (....) 
> Unfortunately, the documentation doesn't seem to indicate that there are
> any 
> special cases where such an error would occur. 

Nick, 

You can only only crop entire raster cells. That is why the docs say that
"the Extent is aligned to the cells of the input RasterLayer." (this could
be elaborated on), and why this is not an error.

You may need to use resample if you want the raster cells to align. (or, if
the misalignment is in fact an error, use shift)

Robert

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Problem-with-extent-of-output-raster-from-crop-function-in-raster-package-tp6519108p6520978.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list