A geospatial package to support skeletonization
Numgeo, a geospatial package
Note: This file is best viewed with support for the Markdown markup language.
Numgeo is a package of Python modules that, at present, primarily supports skeletonization.
In simple terms, the skeleton of a polygon collapses an elongate polygon to a linear form. For example, the outline of a river is a polygon (with a nonzero area). However, we often think of a river in terms of its skeleton, such as when a river is drawn as one or more squiggly lines on a map. Even though those lines do not represent the river's width, they still capture a useful expression of the river's geometry.
The Algorithm, in brief
The algorithm builds on a long history of work by others. It also has a lot of moving parts, but these are the highlights:
- Sample points along the boundary of an input polygon, including around any holes.
- Compute a Voronoi diagram. (https://en.wikipedia.org/wiki/Voronoi_diagram)
- Isolate the "graph skeleton" from the other extraneous bits in the Voronoi diagram (which together make up the graph skeleton's "complement"). For example, each hole in polygon has its own skeleton that should be discarded.
- "Partition out" paths from the graph skeleton to incrementally construct the "partitioned skeleton".
- This is a bit like moving Lego blocks (segments) from one toy box (skeleton) to another, stacking some of them together during the transfer (to form continuous paths of many segments).
- Optionally add "tails" to the paths so that they extend to polygon's boundary rather than stopping short.
- Optionally prune away undesired paths to simplify the skeleton and remove noise.
- This is accomplished using the normalized length metric.
If you're keen to get started, consider the following code (but don't run it just yet!):
from numgeo.scripts.skel import process process(r"path/to/polygon_shapefile.shp", interval=0.1, min_normalized_length=0.)
interval, in effect, specifies the desired resolution of the output skeleton, in map units (e.g., meters). If the narrowest constriction in your input polygons is x map units, you should specify
min_normalized_length, in effect, specifies how simple you want the output skeleton to be, with higher values corresponding to greater simplicity. Any value less than 1. results in no simplification, so the "raw" skeleton itself is output, which may have a lot of unwanted bits.
Therefore, if you were to run the example code, you'd derive a "raw" skeleton at a resolution of 0.1 m (if your map unit is one meter). Because you did not specify an output path, the skeleton would default to path/to/polygon_shapefile_skel.shp.
- It is highly recommended that you read the documentation on Installation before installing numgeo.
- Processing time and memory use both increase exponentially with progressively smaller
intervalvalues, so be careful when choosing a value.
- You might consider calling
process(...)a few times, each time with different
min_normalized_lengthvalues, to build an intuition for how these arguments affect the output skeleton.
- In that case, you can specify
out_path_prefixto avoid overwriting previous outputs. For example,
out_path_prefix="A_"would output to path/to/A_polygon_shapefile_skel.shp.
- In that case, you can specify
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size numgeo-0.0.1a0-py2-none-any.whl (224.9 kB)||File type Wheel||Python version py2||Upload date||Hashes View|
|Filename, size numgeo-0.0.1a0.tar.gz (196.1 kB)||File type Source||Python version None||Upload date||Hashes View|