Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
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. –  digitalmaps Mar 9 '12 at 2:46
    
With your help @klewis I have now answered my own question on StackOverflow stackoverflow.com/questions/9595117/… –  digitalmaps Mar 9 '12 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. –  digitalmaps Mar 9 '12 at 4:15
    
Thanks to @Spacedman on StackOverflow (stackoverflow.com/a/9643004/1165618) for developing an R-based solution to this problem. –  digitalmaps Mar 10 '12 at 3:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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