Skip to main content

A geospatial package to support skeletonization

Project description

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:

  1. Sample points along the boundary of an input polygon, including around any holes.
  2. Compute a Voronoi diagram. (https://en.wikipedia.org/wiki/Voronoi_diagram)
  3. 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.
  4. "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).
  5. Optionally add "tails" to the paths so that they extend to polygon's boundary rather than stopping short.
  6. Optionally prune away undesired paths to simplify the skeleton and remove noise.
    • This is accomplished using the normalized length metric.

Quick start

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 interval <0.5x.

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.

Quick tips:

  1. It is highly recommended that you read the documentation on Installation before installing numgeo.
  2. Processing time and memory use both increase exponentially with progressively smaller interval values, so be careful when choosing a value.
  3. You might consider calling process(...) a few times, each time with different interval and min_normalized_length values, to build an intuition for how these arguments affect the output skeleton.
    • In that case, you can specify out_path_prefix to avoid overwriting previous outputs. For example, out_path_prefix="A_" would output to path/to/A_polygon_shapefile_skel.shp.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numgeo-0.0.1a0.tar.gz (196.1 kB view details)

Uploaded Source

Built Distribution

numgeo-0.0.1a0-py2-none-any.whl (224.9 kB view details)

Uploaded Python 2

File details

Details for the file numgeo-0.0.1a0.tar.gz.

File metadata

  • Download URL: numgeo-0.0.1a0.tar.gz
  • Upload date:
  • Size: 196.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for numgeo-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 9b5c9fe0e65a2170fac81fc18def90e6650a206b89b88ac2740860dc0f37f912
MD5 4f9c634b95b00cca148f9ccdcdacb888
BLAKE2b-256 d7c063bc6e0c6e44326196cc3ea6feea9f470f80fdb441e6c4a3b0bdfd0587d0

See more details on using hashes here.

File details

Details for the file numgeo-0.0.1a0-py2-none-any.whl.

File metadata

  • Download URL: numgeo-0.0.1a0-py2-none-any.whl
  • Upload date:
  • Size: 224.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for numgeo-0.0.1a0-py2-none-any.whl
Algorithm Hash digest
SHA256 d43214195c96b545791571c8d1cf4e8fad986f556d25a57ad6a2b0f4edb451d7
MD5 f62edf4fbc9e1b2daf4bdede4aa9fb58
BLAKE2b-256 4428ae9c10d2d5e459a52eb33c73c79ee0bbcdbbf66db5f32717d37e95956e5f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page