8

I am trying to find a tool to create a skeleton of a large vector dataset using QGIS and its bundle. It should be directly programmatically callable through Python or commandline (QGIS, GRASS, OGR etc. are all okay).

The target is a large thin polygon with holes representing street areas and I need to obtain an approximation of the road network via skeletonization.

What I found so far:

  • GRASS 7.0 has v.skeleton which should be good enough but does not seem to be in for integration with QGIS in the near future.
  • CGAL has skeletonize algorithms, of course, but the Python support is very poor.
  • pySkeleton does not work for me and I probably don't have time to salvage the code.

Other alternatives (openJump skeletonizer, this old ArcGIS plugin...) cannot be easily plugged into QGIS/Python.

Any other suggestions?

  • 4
    GRASS 7.0 is "directly programmatically callable through Python or commandline", so why must your solution also be so tightly bound to QGIS? Also, what about PostGIS? How is your data stored? – Richard Law Nov 22 '15 at 20:39
  • 2
    I'd like to post the solution as a directly usable QGIS plugin - therefore I'd like to stick to the GRASS version bundled by QGIS. – Jan Šimbera Nov 22 '15 at 21:23
6

This document "Skeletonizing Polygons Using PostGIS" describes a process which utilises tools from PostGIS and GRASS, both of which might be callable. It mentions using PostGIS to create a skeleton of the vectors and cleaning it up using either PostGIS again or GRASS.

There are existing tools from the Processing Toolbox which hopefully simplifies things when calling from Python/command line such as:

Hope this helps!

  • Thanks! However, I have to suppose that no PostGIS is installed... – Jan Šimbera Dec 1 '15 at 11:30
  • @JanŠimbera - Most welcome buddy and good luck! Sounds like a very interesting problem you have :) – Joseph Dec 1 '15 at 11:37
4

One, somewhat round-about option might be to use SAGA's grid skeletonization module (http://www.saga-gis.org/saga_module_doc/2.1.3/imagery_segmentation_1.html), either through QGIS or using the command line saga_cmd utility. You'd have to convert your polygon to a SAGA raster first.

Otherwise, as stated by @Alpha-beta-soup, you could use v.skeleton from GRASS on the command line.

To use a commnand line tool from within Python, use the subprocess module to pass the command string to the system.

  • Thanks for the suggestion. I'd rather not convert to raster as the extent is large and I need the result with a fine resolution; I'm thinking about that as a last resort option. – Jan Šimbera Nov 22 '15 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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