[GRASS-user] Calculating a raster "polygon density" map

Brent Wood b.wood at niwa.co.nz
Mon Nov 20 20:13:19 EST 2006


Matthew Perry wrote:
> Hey folks,
>
>  I'm trying to rasterize a polygon vector layer as a polygon density
> map. In other words instead of each cell containing NULL or the
> underlying vector attribute (v.to.rast), I'd like each raster cell to
> represent the percent of the cell's area covered by polygons.
>
> Is there an existing function that can handle this? Has anyone tried
> creating such a polygon density function in GRASS or GDAL/OGR?
>
> Thanks for the input,

I've recently done a similar exercise with polygons representing the 
swept area of commercial fishing trawls and a grid polygon layer.

The "raster" layer is a table of square polygons forming a grid covering 
the area of interest.

A simple SQL joins the two tables (400,000 cells & 1,000,000 tow 
polygons), giving 5,000,000 records & the intersections of the two 
layers, ie: each tow is divided up into the cells it crosses. Given the 
output includes cell_id, SQL queries to determine the aggregate swept 
area within a cell, which can be many times the cell area, the area of 
each cell which has or has not been fished, etc are trivial & pretty fast.

So my solution was not a raster one as you suggest , but used a vector 
layer of cells which functioned in a similar way. It is then trivial to 
get the data into GRASS (for you) or GMT & R (for me :-) using a XYZ 
dataset of grid centroids & whatever Z value I want to use


Cheers,

  Brent Wood




More information about the grass-user mailing list