Split GeoJSON by feature count or file size and convert GeoJSON to and from GeoPackage
Project description
GeoSplit
A focused command-line tool that:
- splits a GeoJSON
FeatureCollectionby feature count; - splits it by a strict maximum file size; and
- converts GeoJSON to GeoPackage, or a GeoPackage layer back to GeoJSON.
The splitter uses a lightweight streaming parser, preserves coordinate precision, and bounds memory use to the current output chunk. GeoPackage support is optional.
View general or command-specific help at any time:
geosplit help
geosplit help split
geosplit help convert
Install
Requires Python 3.10 or newer. Install GeoSplit from PyPI:
python -m pip install geosplit
Include conversion support:
python -m pip install "geosplit[gpkg]"
Confirm the installation:
geosplit help
If the geosplit command is not on your system path, use python -m geosplit help and replace geosplit with python -m geosplit in the examples below.
Split GeoJSON
By feature count:
geosplit split world.geojson output --features 1000
Omit the output directory to create world_split . Specifying Output directory is optional:
geosplit split world.geojson --features 1000
By maximum file size:
geosplit split world.geojson output --size 10MB
Preview every output file, feature count, size, warning, and conflict without writing anything:
geosplit split world.geojson output --features 1000 --dry-run
Sizes accept B, KB, KiB, MB, MiB, GB, and GiB. Each resulting file is a complete, compact GeoJSON document whose on-disk size does not exceed the requested limit. If one feature cannot fit by itself, the command stops with a clear error.
Output files are numbered automatically, such as world_001.geojson, world_002.geojson, and so on. Use --prefix countries to customize their names or --force to replace files recorded in GeoSplit's hidden output manifest. Progress is written to stderr; use --quiet to suppress it. Interrupted transactions are recovered on the next run. A source collection's top-level bbox is omitted because it would no longer describe each split collection; other top-level metadata is retained.
Python API
Stream validated collections without writing files:
from geosplit import iter_batches
for collection in iter_batches("world.geojson", features=1000):
process(collection)
Plan a split, or inspect the result of a completed split:
from geosplit import plan_split, split_geojson
plan = plan_split("world.geojson", features_per_file=1000)
result = split_geojson("world.geojson", features_per_file=1000)
print(plan.files)
print(result.files)
print(result.feature_count)
print(result.total_bytes)
Show the installed version with geosplit --version.
Convert formats
# GeoJSON to GeoPackage
geosplit convert roads.geojson roads.gpkg
# Choose the new GeoPackage layer name
geosplit convert roads.geojson map.gpkg --output-layer roads
# GeoPackage to GeoJSON
geosplit convert map.gpkg roads.geojson --layer roads
If a GeoPackage contains exactly one layer, --layer is optional. Existing destinations are protected unless --force is supplied.
Update
python -m pip install --upgrade geosplit
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geosplit-0.4.1.tar.gz.
File metadata
- Download URL: geosplit-0.4.1.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a5219d4545829dc469015924dc69f48083ec8671f3a0ea2d8466ff6d1e7efc0
|
|
| MD5 |
65f633978840fa53e2c22e75d6ee2ef3
|
|
| BLAKE2b-256 |
2811fdd3899ff584c500e78ead3e8ba98a2c1da798a1b8453fe9a0cfedd9b2c4
|
Provenance
The following attestation bundles were made for geosplit-0.4.1.tar.gz:
Publisher:
release.yml on KoaOkano/GeoSplit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geosplit-0.4.1.tar.gz -
Subject digest:
7a5219d4545829dc469015924dc69f48083ec8671f3a0ea2d8466ff6d1e7efc0 - Sigstore transparency entry: 2060583687
- Sigstore integration time:
-
Permalink:
KoaOkano/GeoSplit@d3b046f16992ecb5017c22679a303bff5ee329d2 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/KoaOkano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d3b046f16992ecb5017c22679a303bff5ee329d2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file geosplit-0.4.1-py3-none-any.whl.
File metadata
- Download URL: geosplit-0.4.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a4ae6f9917de7d3deb07be2717d7ab31fedbd17f3d1a2fae456fb4b6ed891e7
|
|
| MD5 |
6e4610ab875e529322f01d56a6a4248b
|
|
| BLAKE2b-256 |
32b27b1ddea52f7b56c017ca46f2b6113f4410139d6bbac611a3d001f98ce639
|
Provenance
The following attestation bundles were made for geosplit-0.4.1-py3-none-any.whl:
Publisher:
release.yml on KoaOkano/GeoSplit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geosplit-0.4.1-py3-none-any.whl -
Subject digest:
4a4ae6f9917de7d3deb07be2717d7ab31fedbd17f3d1a2fae456fb4b6ed891e7 - Sigstore transparency entry: 2060583929
- Sigstore integration time:
-
Permalink:
KoaOkano/GeoSplit@d3b046f16992ecb5017c22679a303bff5ee329d2 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/KoaOkano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d3b046f16992ecb5017c22679a303bff5ee329d2 -
Trigger Event:
release
-
Statement type: