[R-sig-Geo] Raster stream network to lines
Andy Bunn
Andy.Bunn at wwu.edu
Wed Apr 18 21:03:21 CEST 2018
I have a raster of streams with 0 being non-stream and 1 being stream. Is there a way to convert this into a SpatialLinesDataFrame? rasterToContour() almost does what I want but fails to draw the line on queens rules, etc. Example here:
library(raster)
foo <- matrix(0,ncol=9,nrow=9)
foo[1:4,3] <- 1
foo[5,4] <- 1
foo[6:9,5] <- 1
foo <- raster(foo)
plot(foo)
bar <- rasterToContour(foo,nlevels=1)
plot(bar)
How can I get a continuous line in this example? Many thanks, Andy
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list