Skip to main content

topojson - a powerful library to encode geographic data as topology in Python!🌍

Project description

topojson

PyPI version License github actions Conda version shapely, numpy 2.0 compliant

Encode spatial data as topology in Python!

Topojson is a library that is capable of creating a topojson encoded format of merely any spatial object in Python.

With topojson it is possible to reduce the size of your spatial data. Mostly by orders of magnitude. It is able to do so through:

  • Eliminating redundancy through computation of a topology
  • Fixed-precision integer encoding of coordinates and
  • Simplification and quantization of arcs

See Topojson Documentation Site for all info how to use this package.

Usage

The package can be used in multiple different ways, with the main purpose to create a TopoJSON topology.

See the Python Topojson Documentation Site for all info or this Notebook with some examples, such as the following:

click to open notebook

Click on the image to go the Notebook Viewer with code-snippets how these images are created or visit the Topojson Documentation Site.

Installation

Installation can be done through PyPI by the following command:

python -m pip install topojson

And through conda using the following command:

conda install topojson -c conda-forge

This package topojson has the following hard dependencies:

  • numpy
  • shapely
  • packaging

Further, optional soft dependencies are:

  • altair - enlarge the experience by visualizing your TopoJSON output
  • simplification - more and quicker simplification options
  • geojson - parse string input with GeoJSON data
  • geopandas - parse your TopoJSON output directly into a GeoDataFrame
  • ipywidgets + (lab)extension - make your life complete with the interactive experience

Other resources

For a better understanding how the different included simplification algorithms work

  • rdp: Ramer–Douglas–Peucker
  • vw: Visvalingam-Whyatt

You can have a look to this blog post on Line simplification algorithms. There you can find out that the epsilon value for vw is area-based and that the epsilon value for rdp is distance-based.

Also, if your source projection is in meters, than it is very likely that your epsilon value should be magnitudes larger than the examples on this page where the source projection is in degrees.

There is a section on simplification in the book on 'Geocomputation with Python' that describes toposimplification as follow:

The main advantage of .toposimplify is that it is topologically “aware”: it simplifies the combined borders of the polygons (rather than each polygon on its own), thus ensuring that the overlap is maintained.

Get in touch

For now, just use the Github issues. That can be:

  • usage questions
  • bug reports
  • feature suggestions
  • or anything related

Finally, see the Python Topojson Documentation Site for all info how to use this package.

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

topojson-1.10.tar.gz (25.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

topojson-1.10-py3-none-any.whl (83.3 kB view details)

Uploaded Python 3

File details

Details for the file topojson-1.10.tar.gz.

File metadata

  • Download URL: topojson-1.10.tar.gz
  • Upload date:
  • Size: 25.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for topojson-1.10.tar.gz
Algorithm Hash digest
SHA256 a7f53406324061a0310bec46740a6609147c24daeb354596c68345b9527b38c1
MD5 abda2c7365f77bf3b982eb051d88727b
BLAKE2b-256 79f374330050d8f7e05e140e6043302f71524e159f9a83bbee9681c86282f8fd

See more details on using hashes here.

File details

Details for the file topojson-1.10-py3-none-any.whl.

File metadata

  • Download URL: topojson-1.10-py3-none-any.whl
  • Upload date:
  • Size: 83.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for topojson-1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0879d727c7798939e3268e8969fa87c2cd23274189fe3d8038a0fb11ff263925
MD5 2f63233b6e6ca6889236f29553158902
BLAKE2b-256 6f7a2a8ea3b2b6e50cbec74c53082b69617d71f31e1247e35e65bf9a6edc44cf

See more details on using hashes here.

Supported by

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