[R-sig-Geo] Apply rasterize so that it includes ALL cells touching a polygon

Tara Bridwell tarabridwell at gmail.com
Fri Mar 2 19:12:38 CET 2012


Hi list members,
I have seen this post
(http://r-sig-geo.2731867.n2.nabble.com/Clip-a-raster-tt5635474.html#a5639429)
but I am wondering if there is a more straightforward way have
rasterize include ALL of the cells touching a polygon and not just
those where more than half the edge is covered.

Some code:

# I import the polygon:
polygon <- readOGR(".","nms",p4s = "+proj=longlat +ellps=WGS84 +datum=WGS84")

# I read in my raster
r1 <- readGDAL("raster", p4s = "+proj=longlat +ellps=WGS84 +datum=WGS84")
r1.r <- raster(r1)
polygon.r <- rasterize(polygon, r1.r, fun=max)

Thanks,
Tara



More information about the R-sig-Geo mailing list