from vector to raster (2nd try) with R or GRASS (GRASS prefered...)

2 messages Options
Embed this post
Permalink
Alexandre VILLERS

from vector to raster (2nd try) with R or GRASS (GRASS prefered...)

Reply Threaded More More options
Print post
Permalink
Good morning,

I try to be clearer than I was in my precedent post and also copy this
to the R SIG GEO.
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.
Being a beginner, I tried different ways but got stuck quite rapidely.

Any help appreciated.


Alex

--
Alexandre Villers
PhD Student
Team "Biodiversity"
Centre d'Etudes Biologiques de Chizé-CNRS UPR1934
79360 Beauvoir sur Niort

Phone +33 (0)5 49 09 96 13
Fax   +33 (0)5 49 09 65 26




__________ Information from ESET Mail Security, version of virus signature database 4439 (20090918) __________

The message was checked by ESET Mail Security.
http://www.eset.com


_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Tim Holland

Re: from vector to raster (2nd try) with R or GRASS (GRASS prefered...)

Reply Threaded More More options
Print post
Permalink

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