[R-sig-Geo] Intersect polygon with grid
p.hiemstra at geo.uu.nl
Tue Dec 22 13:02:18 CET 2009
A simple approach would be the following:
1. Create a point dataset that comprises of the center points of the grid
2. Overlay the pointset with the polygon set using the overlay() command
3. Convert the pointset into a grid using the gridded() command
A problem could be that if your polygons are small in regard to the
gridsize, only the center point of the gridcell determines the value of
the gridcell. It does not look at how much area from several polygons is
in a gridcell, and creating a weigted average by area. You could remedy
this by making the pointset much denser, doing step 1-3 and then
aggregating the dense grid into a coarser grid, calculating for example
the mean. This can be done using the pointsToRaster() function from the
Johannes Signer wrote:
> Dear List,
> I am trying to do the following:
> I have a shapefile, that I want to overlay with a raster and then assign
> each raster cell a value that represents the percentage covered by the shape
> file. I have found a way to do that with small data sets, but I am
> struggling with large datasets (1mio+ cells).
> My approach so far is:
> 1.) Create rectangular polygons (covering the whole area), that will be used
> for the grid afterwards.
> 2.) Intersect the each polygon with the shapefile and calculate the area.
> 3.) Create a grid from the rectangular polygons.
> Any suggestions are very welcome!
> Thanks in advance
> [[alternative HTML version deleted]]
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
P.O. Box 80.115
3508 TC Utrecht
Phone: +3130 274 3113 Mon-Tue
Phone: +3130 253 5773 Wed-Fri
More information about the R-sig-Geo