[R-sig-Geo] Import raster from ArcGIS - mismatch between original GRID and raster in R
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Wed Dec 7 11:14:08 CET 2011
On Tue, Dec 6, 2011 at 11:48 PM, Jenn.B <jsbarret at sfu.ca> wrote:
> After a little investigating I noticed
> that the GRID gets resampled when imported into R, such that my location,
> which is near land, now falls on land (and thus not on a value cell). How
> can I avoid this? Is there some argument I can apply to "snap" the raster to
> the original GRID? This is a serious problem, as I imagine I'll encounter
>
> # Import raster layer - ocean + freshwater = 1, land = NoData
> r.CS<- raster ("C:/myfile")
I think you need to see what r.CS is here, and compare it to your
ArcGIS raster. What does summary(r.CS), or even print(r.CS), give -
then compare that to whatever ArcGIS' summary function spits out -
dimensions, bounding boxes etc. They should be the same. Ditto your
transition matrix.
One thing you might not have noticed is that big rasters get
downsampled when _plotting_ - so you might see a point on 'land' which
is really on water once you've zoomed in far enough to see the cells.
The raster package 'zoom' function is very handy in this respect. Zoom
and add your points (with the points function) until you can really
see the cells.
Check the raster in R is really at the coordinates it says it is.
Sometimes rasters get aligned to their cell edges instead of cell
centres (or vice versa). Zoom in on the corners and check the edges.
Adding axes (axis(1);axis(2)) helps for visual reference, and adding
vertical and horizontal lines (abline(h=XX) and abline(v=XX)) helps
too.
Of course it may end up that your point is right on a cell boundary
and a minor arithmetic calculation difference between ArcGIS and R is
putting this coordinate on land! (what sort of bird nests on water
anyway?)
Barry
More information about the R-sig-Geo
mailing list