Skip to content
Prev 9981 / 29559 Next

Pixel reference location?

Hi Lyndon,

That clarifies what happens with 'crop' I think; but the different
georeferencing info you get from Arc and ENVI is puzzling. Your
question about georeferencing was clear, but my answer was not.
Another try: raster uses the extreme of the extreme cells for
georeferencing as in:

xoooo
ooooo
ooooo

i.e. (1,1), not (1.5, 1.5)

However, you say that Arc & ENVI put the coordinates half a cell
beyond where raster puts them (and now I understand where your
question came from), this is pretty serious as it suggest that they
are reading something different in the file. Could you send me the
file?


The cropping part:

to.crop <- raster(nrow=9872, ncol=6976, xmn = -283139.2, xmx =
1332896, ymn = -1172417, ymx = 1114495)
crop.img <- raster(nrow=6116, ncol=4200,  xmn = -120863.9, xmx =
852092.8, ymn = -497022.6, ymx = 919787.6)

# What happens here:
cropped <- crop(to.crop, crop.img)
# is:
#1) get the intersection of to.crop and crop.img
e = intersectExtent(to.crop, crop.img)
#2) align the intersection with the raster that needs to be cropped
ee = alignExtent(e, to.crop)
cropped <- crop(to.crop, ee)

I suggested to use the extent function but I am now less sure about
that because there seems to be something else going on.

Best, Robert
On Sat, Nov 13, 2010 at 11:58 AM, Lyndon Estes <lestes at princeton.edu> wrote:
It was just confusing to debug, if it all works it might be OK