Skip to main content

GeoJSON network simplification using raster image skeletonization and Voronoi polygons

Project description

parenx

Simplify (or "pare") a GeoJSON network ("nx") using raster image skeletonization an Voronoi polygons

Provides functions that use image skeletonization or Voronoi polygons to simplify geographic networks composed of linestrings. The outputs are geographic layers representing simplified or 'primal' representations of the network. Primal networks only contains straight line segments

Sample datasets include:

Installation

Install the package into an activated python virtual environment with the following command:

pip install parenx

Install the latest development version from GitHub with the following command:

pip install git+https://github.com/anisotropi4/parenx.git

This places the skeletonization.py and voronoi.py scripts into the executable search path.

Test to see if the package is installed with the following command:

python -c "import parenx; print(parenx.__version__)"

Examples

A bash helper script run.sh and example data is available under the sitepackage project directory under venv. The exact path varies with module and python version

Skeletonization

The following creates a simplified network by applying skeletonization to a buffered raster array in output.gpkg

# Download the data if not already present
if [ ! -f ./data/rnet_princes_street.geojson ]; then
    wget https://raw.githubusercontent.com/anisotropi4/parenx/main/data/rnet_princes_street.geojson
    # Create data folder if not already present
    if [ ! -d ./data ]; then
        mkdir ./data
    fi
    mv rnet_princes_street.geojson ./data
fi
skeletonize.py ./data/rnet_princes_street.geojson rnet_princes_street_skeletonized.gpkg

Voronoi

The following creates a simplified network by creating set of Voronoi polygons from points on the buffer in output.gpkg

voronoi.py ./data/rnet_princes_street.geojson rnet_princes_street_voronoi.gpkg

Simple operation

The run.sh script sets a python virtual environment and executes the script against a data file in the data directory

$ ./run.sh

The run.sh script optionally takes a filename and file-extension. To simplify a file, say somewhere.geojson and output to GeoPKG files sk-simple.gpkg and vr-simple.gpkg

$ ./run.sh somewhere.geojon simple

Locating the run.sh script

To copy the run.sh script into your local directory the following could help

$ find . -name run.sh -exec cp {} . \;

Notes

Both are the skeletonization and Voronoi approach are generic approaches, with the following known issues:

  • This does not maintain a link between attributes and the simplified network
  • This does not identify a subset of edges that need simplification
  • The lines are a bit wobbly
  • It is quite slow

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

parenx-0.6.1.tar.gz (179.4 kB view details)

Uploaded Source

Built Distribution

parenx-0.6.1-py3-none-any.whl (189.1 kB view details)

Uploaded Python 3

File details

Details for the file parenx-0.6.1.tar.gz.

File metadata

  • Download URL: parenx-0.6.1.tar.gz
  • Upload date:
  • Size: 179.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for parenx-0.6.1.tar.gz
Algorithm Hash digest
SHA256 51e99ca2d51143e7b0cac389d8ad25942b5a764dd9f9100eadcae97dd8ad4c4d
MD5 f4f20a28e637ee55be0d9672f4ad520b
BLAKE2b-256 d64a84ca8cb331c74dcc7b5a33e39812c616552b3e7c7dbdd6feaecfa32e5d29

See more details on using hashes here.

File details

Details for the file parenx-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: parenx-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 189.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for parenx-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf7873bb9deb0ad98b9e9fffa00931639314991fe004264b26e4a3d39b7a8fc6
MD5 5067e260a66f7e275c2caf1bc8cc4090
BLAKE2b-256 c099a294ce97eb8d960de2912838bc6d9d0ea8a4cbfb9ba735806db4049a33d2

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