Split and validate GeoJSON, split GeoPackage layers, and convert GeoJSON to and from GeoPackage
Project description
GeoSplit
GeoSplit safely validates GeoJSON, splits a GeoJSON FeatureCollection, splits GeoPackage layers by feature count, and converts GeoJSON to and from GeoPackage.
The GeoJSON splitter streams large inputs, preserves coordinate precision, limits memory to the active output chunk, checks available disk space, and uses recoverable output transactions. GeoPackage support is optional.
Install
GeoSplit requires Python 3.10 or newer:
python -m pip install geosplit
On Windows, py can be used instead:
py -m pip install geosplit
Install optional GeoPackage support:
python -m pip install "geosplit[gpkg]"
Check the installation:
geosplit --version
geosplit --help
geosplit help split
geosplit help validate
If geosplit is not on your PATH, replace it with python -m geosplit or, on Windows, py -m geosplit.
Validate GeoJSON
Validate a complete file without creating output:
geosplit validate input.geojson
The report includes feature and geometry counts, null geometries, maximum nesting, coordinate dimensions, and warnings. Invalid geometry errors identify the feature and coordinate path.
Produce a machine-readable report:
geosplit validate input.geojson --json
Validation checks JSON and GeoJSON structure, recognized geometry types, coordinate nesting, numeric finite coordinates, polygon ring length and closure, trailing data, and the nesting safety limit. It does not check geographic topology such as polygon self-intersections or silently repair data.
Split GeoJSON and GeoPackage
Split every 1,000 features:
geosplit split world.geojson --features 1000
The output directory is optional. When omitted, GeoSplit creates world_split beside the input. To choose it explicitly:
geosplit split world.geojson output --features 1000
Split using an exact maximum output size:
geosplit split world.geojson output --size 10MB
Sizes accept B, KB, KiB, MB, MiB, GB, and GiB. Every output is a complete compact GeoJSON document. A feature that cannot fit by itself produces an error.
Split a GeoPackage layer by feature count:
geosplit split roads.gpkg --features 1000
If a GeoPackage contains multiple layers, choose one:
geosplit split map.gpkg --layer roads --features 1000
GeoPackage input creates GeoPackage output files and keeps the same layer name inside every chunk. Size-based splitting is not supported for GeoPackage input. Use --features instead.
Preview with dry-run
Show planned files, feature counts, sizes, warnings, and conflicts without creating anything:
geosplit split world.geojson --features 1000 --dryrun
Dry-run still reads and validates the complete input. The older spelling --dry-run is still accepted.
Other split options
Choose the output filename prefix:
geosplit split world.geojson --features 1000 --prefix countries
Replace output files previously managed by GeoSplit:
geosplit split world.geojson --features 1000 --force
Suppress progress and success output for scripts:
geosplit split world.geojson --features 1000 --quiet
Options can be combined:
geosplit split world.geojson output --size 50MiB --prefix region --force --quiet
Output files are numbered automatically, for example world_001.geojson or roads_001.gpkg. GeoSplit preserves top-level GeoJSON metadata except bbox, which would no longer describe each split collection. Interrupted transactions are recovered on the next run.
In an interactive terminal, long-running split, validate, and convert commands show progress, for example:
Reading features 45,000 / 180,000
Writing chunks 12 / 48
Validating output 48 / 48
Use --quiet with split to suppress split progress and success output. Validation JSON output stays machine-readable and does not include progress text.
Convert GeoJSON and GeoPackage
Install geosplit[gpkg] first, then run:
# GeoJSON to GeoPackage
geosplit convert roads.geojson roads.gpkg
# Select 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
# Replace an existing destination
geosplit convert roads.geojson roads.gpkg --force
If a GeoPackage contains exactly one layer, --layer is optional.
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 without writing, then perform a 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)
Use max_bytes instead of features_per_file for exact-size splitting.
Validate from Python:
from geosplit import validate_geojson
report = validate_geojson("world.geojson")
print(report.valid)
print(report.feature_count)
print(report.geometry_counts)
print(report.errors)
Safety behavior
- Existing output is protected unless
--forceis supplied. --forceonly replaces files tracked by GeoSplit or recognized legacy output.- Output is staged before replacing existing files.
- Coordinate values retain their parsed decimal precision.
- Invalid geometry structure, non-finite coordinates, corrupt JSON, and excessive nesting are rejected.
- A disk-space estimate is checked before staging; operating-system write errors are still handled if free space changes later.
Update
python -m pip install --upgrade geosplit
Contributing and security
See CONTRIBUTING.md and SECURITY.md.
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.5.5.tar.gz.
File metadata
- Download URL: geosplit-0.5.5.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1141cda44953225919f1109412310a70f7ff83b9f1433972502d95d69158968
|
|
| MD5 |
1cebe1ffe70e381a102fe6b42d82ab84
|
|
| BLAKE2b-256 |
cff8ea764902c070e8e103333899e6239ebbef151414cd126fe56603bdd046af
|
Provenance
The following attestation bundles were made for geosplit-0.5.5.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.5.5.tar.gz -
Subject digest:
f1141cda44953225919f1109412310a70f7ff83b9f1433972502d95d69158968 - Sigstore transparency entry: 2091486767
- Sigstore integration time:
-
Permalink:
KoaOkano/GeoSplit@da1e294a64f422c7c92da3e41b231e574f85411a -
Branch / Tag:
refs/tags/v0.5.5 - Owner: https://github.com/KoaOkano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da1e294a64f422c7c92da3e41b231e574f85411a -
Trigger Event:
release
-
Statement type:
File details
Details for the file geosplit-0.5.5-py3-none-any.whl.
File metadata
- Download URL: geosplit-0.5.5-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c2f0eb3a7d746c61bbde21feea22accc7dc9e0e1febcc762014371d3cc49d96
|
|
| MD5 |
0266cebea7a910aa06db6d939d0db96f
|
|
| BLAKE2b-256 |
a974de233c72084c43256223d15be4f7dd67990d4e337495b7979a1a3766b059
|
Provenance
The following attestation bundles were made for geosplit-0.5.5-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.5.5-py3-none-any.whl -
Subject digest:
6c2f0eb3a7d746c61bbde21feea22accc7dc9e0e1febcc762014371d3cc49d96 - Sigstore transparency entry: 2091486976
- Sigstore integration time:
-
Permalink:
KoaOkano/GeoSplit@da1e294a64f422c7c92da3e41b231e574f85411a -
Branch / Tag:
refs/tags/v0.5.5 - Owner: https://github.com/KoaOkano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da1e294a64f422c7c92da3e41b231e574f85411a -
Trigger Event:
release
-
Statement type: