[R-sig-Geo] From NCEAS: Notice discrepancy in raster subimages clipped with same extent -

Robert J. Hijmans r.hijmans at gmail.com
Wed Apr 27 03:00:59 CEST 2011


Rick,

This suggests that  inputCDEMRaster and inputAsterCgiarRaster do not
have exactly the same origin (the raster cells do not exactly align --
within the tolerance that raster uses).

While you clip with the same extent, the clipped result is always in
"rounded to the nearest whole cells".

The question is whether this is wrong (caused by rounding or another
error) or not, and whether the difference is big enough to care. If in
fact they do align, or if you do not care, you can use your hack. If
not, resample.

This is the difference. It is small, but you it would be about a
quarter cell if the resolution is 0.008333333
> ymin        : 59.99808
> ymin        : 59.99772

Robert

On Tue, Apr 26, 2011 at 5:49 PM, Rick Reeves <reeves at nceas.ucsb.edu> wrote:
> Hi Robert:
>
> Apologize for not posting this yet on rSigGeo, but I am under
> a bit of time pressure:
>
> When clipping two images with the same extent object:
>
> Browse[2]> eTestAreaExtent
> class       : Extent
> xmin        : -135.2
> xmax        : -100.2
> ymin        : 59.998
> ymax        : 60.002
>
> The resulting images have different extents:
>
> rEdgeRegionCDEM <- crop(inputCDEMRaster, eTestAreaExtent)
> rEdgeRegionAsterCgiar <- crop(inputAsterCgiarRaster, eTestAreaExtent)
>
> Browse[2]> extent(rEdgeRegionCDEM)
> class       : Extent
> xmin        : -135.1996
> xmax        : -100.2002
> ymin        : 59.99808
> ymax        : 60.00224
> Browse[2]> extent(rEdgeRegionAsterCgiar)
> class       : Extent
> xmin        : -135.1998
> xmax        : -100.2003
> ymin        : 59.99772
> ymax        : 60.00189
>
> ..As a result, the command:
>
> rDelta <- rEdgeRegionAsterCgiar - rEdgeRegionCDEM
>
> results in:
>
> Error in compare(e1, e2, extent = FALSE, rowcol = FALSE, prj = TRUE, res =
> TRUE,  :
>  different origin
>
> if I add the 'hack':
>
> extent(rEdgeRegionCDEM) <- extent(rEdgeRegionAsterCgiar)
>
> Then the subtraction operation works. But I doubt the true
> absolute geographic alignment of the two images.
>
> Any insights?
>
> thanks,
> Rick Reeves
> NCEAS
>
>
>
> Using raster package on:
>
> platform       x86_64-pc-linux-gnu
> arch           x86_64
> os             linux-gnu
> system         x86_64, linux-gnu
> status
> major          2
> minor          13.0
> year           2011
> month          04
> day            13
> svn rev        55427
> language       R
> version.string R version 2.13.0 (2011-04-13)
>
>
>



More information about the R-sig-Geo mailing list