Skip to content

raster directions to vectorial lines (Stream to Feature)

1 message · Mauricio Zambrano-Bigiarini

#
Dear List,

I have a raster file representing flow directions, and I would like to 
know if is there any function for transforming this raster file into a 
vectorial representation (with lines)

The original raster only has 9 possible values:

1: 225 deg (South-West)
2: 270 deg (South)
3: 315 deg (South-East)
4: 180 deg (West)
5: NA (no flow)
6:   0 deg (East)
7: 135 deg (North-West)
8:  90 deg (North)
9:  45 deg (North-East)

I can use the function 'reclassify' provided by the raster package to 
re-class the 9 values into the corresponding decimal degrees.
However, I don't know how to create a line from each cell centre to the 
next cell, following the direction stored in each cell.

My colleagues do this with the 'Stream to Feature' tool of Spatial 
Analyst (ArcGis 10.0, 
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000058000000.htm), 
but I would like to do it in R.

I would highly appreciate any ideas about how to carry out this task in R.

Thanks in advance,

Mauricio Zambrano-Bigiarini