[GRASS-stats] from vector to raster (2nd try) with R or GRASS (GRASS prefered...)

Tim Holland timothyholland at gmail.com
Mon Sep 28 08:49:44 EDT 2009




Alexandre VILLERS wrote:
> 
> 
> On the one hand, I have a shape of lines representing roads
> On the other, a GRASS region with a given resolution (250 x 250 meters 
> pixel)
> 
> I would like to create a new raster map identical to my region settings 
> (same resolution, extent, etc.) with the length of roads summed in each 
> pixel.
> 
> 



One way would be to create a raster from your roads file at a smaller
resolution than you want (something that would be divisible by 250, though -
say 25m x 25m pixel, or larger depending how big a file this is).  

g.region rast=rast250 #### to set region boundaries to same as your 250m
raster
g.region res=X #### to set resolution to whatever 'X' meters you decide

v.to.rast input=roads.vect output=roads.rast.resX use=val value=1  ### to
make your roads raster.

Then you need to aggregate your new raster to 250m.  The number of small
pixels that are road within each big pixel should correlate quite well to
the length or roads within the big pixel.  This won't be a perfect
correlation, though - a road that cuts across a pixel on a diagonal will be
1.4 times longer than a road that cuts across a pixel horizontally or
vertically.  The smaller you make the pixels on your first roads raster, the
better the correlation will be.  

I haven't used the tools for aggregating pixels before, but it looks like
r.resamp.stats will probably do what you need.

HTH,
Tim 
-- 
View this message in context: http://n2.nabble.com/from-vector-to-raster-2nd-try-with-R-or-GRASS-GRASS-prefered-tp3674947p3729224.html
Sent from the Grass - Stats mailing list archive at Nabble.com.


More information about the grass-stats mailing list