topojson
topojson - a powerful library to encode geographic data as topology in Python!🌍
What it is and what it does
topojson is a Python library that converts spatial objects (geometries from shapely, GeoJSON, or GeoDataFrames) into TopoJSON format, a topology-aware encoding that dramatically reduces file size. It works by computing shared topology between features, encoding coordinates as fixed-precision integers, and optionally simplifying arcs using either Ramer–Douglas–Peucker or Visvalingam-Whyatt algorithms. The library depends on numpy for numerical operations, shapely for geometry handling, and packaging for version management.
You would use topojson when you need to compress geographic data for transmission, storage, or web visualization—particularly when serving maps or spatial datasets over the network where bandwidth matters. It maintains topological relationships during simplification, so adjacent polygons remain properly aligned after reduction. The library is designed for developers working with geographic information systems, web mapping, or data visualization pipelines.
Use it for:
- Reduce GeoJSON file sizes for web map applications before serving to browsers
- Compress spatial datasets for storage or archival while preserving topology
- Simplify polygon boundaries in geographic data while keeping adjacent regions aligned
- Convert shapely geometries to a compact format for data interchange or APIs
- Prepare geographic data for interactive visualization with tools like Altair
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
topojson encodes spatial data into TopoJSON format, a compressed topology representation that reduces file size by eliminating coordinate redundancy and applying fixed-precision integer encoding and arc simplification.
Yes, if you work with geographic data and need file compression. The library is stable (BSD licensed, no known vulnerabilities), has low install friction, and solves a real problem in geospatial workflows. The aging maintenance status (388 days since last release) is a minor concern for new features but not a blocker for core functionality. Install if you're already using shapely and need TopoJSON output; skip if you don't work with spatial data.
Install
topojson on PyPI
pip
pip install topojsonuv
uv add topojsonpoetry
poetry add topojsonInstalling topojson
Before you install
Low friction: pure Python wheel with three straightforward runtime dependencies (numpy, shapely, packaging). Last commit 2025-07-22 with 198 repository stars; maintenance status is aging (388 days since last release), so expect slower response to new issues.
License in practice
BSD permissive license allows commercial and private use with minimal restrictions, making it safe for most projects.
Quickstart
pip install topojson
import topojson
from shapely.geometry import Polygon
polygon = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])
topo = topojson.Topology(polygon)
Requires Python 3.8 or later; numpy and shapely must be installed and functional.
Verify before relying
- Actual compression ratios and typical file size reductions for real-world datasets
- Performance characteristics and scalability limits for large spatial datasets
- Compatibility with specific GeoJSON or shapely versions beyond the stated dependencies
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, shapely, packaging |
| Maintenance | aging — 388 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 177,203/month — #10,221 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: topojson-1.10-py3-none-any.whl
Keywords: topojson, python, github, topology, geojson
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
polylineEncodes and decodes geographic coordinate…
unclear · top 5,000 on PyPI
osm2geojsonConverts OpenStreetMap and Overpass API data…
permissive · top 15,000 on PyPI
geobufGeobuf encodes GeoJSON to a compact binary…
permissive · top 15,000 on PyPI
geojsonEncodes, decodes, and represents GeoJSON…
permissive · top 5,000 on PyPI
geopandasGeoPandas extends pandas DataFrames to handle…
permissive · top 1,000 on PyPI
overturemapsDownload and convert Overture Maps geospatial…
permissive · top 15,000 on PyPI
reprojReproject shapely geometries between coordinate…
permissive · top 15,000 on PyPI
python-geohashpython-geohash encodes and decodes geographic…
unclear · top 15,000 on PyPI
simplificationSimplify LineStrings using the…
unclear · top 15,000 on PyPI
rdpImplements the Ramer-Douglas-Peucker algorithm…
permissive · top 15,000 on PyPI