6

I would like to identify linear features, such as roads and rivers, on raster maps and convert them to a linear vector features (i.e. polylines). I typically use R as my primary GIS, and have posed this question as it pertains to R, here, at StackOverflow without resolution. Apologies for cross-posting, however, here I am seeking any means to do this efficiently, (preferably, but not necessarily, in a manner that can be automated using code.)

Converting linear features of a certain class on a raster to polygons can be done using rasterToPolygons() in the R package raster, for example. But how can I turn these polygons into polylines objects (i.e. skeletonize these polygons to a centre line) efficiently and reproducibly without resorting to to manual steps in vector graphics software, for example.

1 Answer 1

3

Mr. Huber described the steps to convert polygons to centerlines (Oct 17, 2002). I also found a centerline AML with the exact same steps. It looks pretty easy except you need to create Thiessen or Voronoi polygons as one of the steps.

SAGA/RSAGA creates Voronoi with a Nearest Neighbor module but only in a Grid format, so you might need to vectorize the grid if you go this route.

I recommend using Geoscript (geoscript.geom.geom.voronoi), it will create Voronoi as vectors.

You should be able to script the whole thing.

centerline steps

4
  • 1
    Brilliant, nice find! This just the elegant sort of algorithm I was looking for. I believe there are multiple ways to do Voronoi tessellations in R. This should be quite doable. Commented Mar 9, 2012 at 2:46
  • With your help @klewis I have now answered my own question on StackOverflow stackoverflow.com/questions/9595117/… Commented Mar 9, 2012 at 4:14
  • It turns out that the deldir package does really efficient Voronoi tessellations, and it's a snap to find the centre-line thereafter. Commented Mar 9, 2012 at 4:15
  • Thanks to @Spacedman on StackOverflow (stackoverflow.com/a/9643004/1165618) for developing an R-based solution to this problem. Commented Mar 10, 2012 at 3:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.