Geobuf
Geobuf is a compact binary geospatial format for lossless compression of GeoJSON.
Note well: this project has been transferred by Mapbox to the new pygeobuf organization.
Advantages over using GeoJSON directly (in this revised version):
- Very compact: typically makes GeoJSON 6-8 times smaller.
- Smaller even when comparing gzipped sizes: 2-2.5x compression for GeoJSON.
- Easy incremental parsing — you can get features out as you read them, without the need to build in-memory representation of the whole data.
- Partial reads — you can read only the parts you actually need, skipping the rest.
- Trivial concatenation: you can concatenate many Geobuf files together and they will form a valid combined Geobuf file.
- Potentially faster encoding/decoding compared to native JSON implementations (i.e. in Web browsers).
- Can still accommodate any GeoJSON, including extensions with arbitrary properties.
Think of this as an attempt to design a simple, modern Shapefile successor that works seamlessly with GeoJSON.
Unlike Mapbox Vector Tiles, it aims for lossless compression of datasets — without tiling, projecting coordinates, flattening geometries or stripping properties.
pygeobuf
This repository is the first encoding/decoding implementation of this new major version of Geobuf (in Python). It serves as a prototyping playground, with faster implementations in JS and C++ coming in future.
Sample compression sizes
| normal | gzipped | |
|---|---|---|
| us-zips.json | 101.85 MB | 26.67 MB |
| us-zips.pbf | 12.24 MB | 10.48 MB |
| us-zips.topo.json | 15.02 MB | 3.19 MB |
| us-zips.topo.pbf | 4.85 MB | 2.72 MB |
| idaho.json | 10.92 MB | 2.57 MB |
| idaho.pbf | 1.37 MB | 1.17 MB |
| idaho.topo.json | 1.9 MB | 612 KB |
| idaho.topo.pbf | 567 KB | 479 KB |
Usage
Installation:
pip install geobuf
Command line:
geobuf encode < example.json > example.pbf
geobuf decode < example.pbf > example.pbf.json
As a module:
import geobuf
pbf = geobuf.encode(my_json) # GeoJSON -> Geobuf string
my_json = geobuf.decode(pbf) # Geobuf string -> GeoJSON
The encode function accepts a dict-like object, for example the result of json.loads(json_str).
Both encode.py and geobuf.encode accept two optional arguments:
- precision — max number of digits after the decimal point in coordinates,
6by default. - dimensions — number of dimensions in coordinates,
2by default.
Tests
py.test -v
The tests run through all .json files in the fixtures directory,
comparing each original GeoJSON with an encoded/decoded one.
Generating from geobuf.proto
To (re-)generate the geobuf_pb2.py file, you can run the following
commands:
protoc geobuf.proto --python_out=geobuf
Metadata
Release files for geobuf 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| geobuf-2.0.1.tar.gz | 46.6 kB | Without provenance | Details for geobuf-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| geobuf-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for geobuf-2.0.1-py3-none-any.whl |
Total release size: 56.4 kB
Release files / geobuf-2.0.1.tar.gz
| Download URL | geobuf-2.0.1.tar.gz |
|---|---|
| Size | 46.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73f173e42e50ca546ad81be8ac33511bf09d0fcb58799fa50ef0ee5f01c77561
|
|
BLAKE2b-256 checksum How to use checksums |
fdd4538d7d6c6524022bf91ed35a411913cef0e00dcb70fd3b9d3776be631f6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / geobuf-2.0.1-py3-none-any.whl
| Download URL | geobuf-2.0.1-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8407af71134aa1e2e55e2ae1d2d241b2c2345e2904de7cca48eb441ee6f2e5d
|
|
BLAKE2b-256 checksum How to use checksums |
41d6d02c66ce9dc888f663b127062f43cbdbaa5f4a37dfeaa6937aa5fe67a963
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for geobuf 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.