Split GeoJSON by feature count or file size and convert GeoJSON to and from GeoPackage
Project description
GeoSplit
GeoSplit safely splits a GeoJSON FeatureCollection by feature count or exact file size. It can also convert GeoJSON to and from GeoPackage.
The splitter streams large inputs, preserves coordinate precision, limits memory to the active output chunk, checks available disk space, and uses recoverable output transactions.
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
If geosplit is not on your PATH, replace it with python -m geosplit or, on Windows, py -m geosplit.
Split GeoJSON
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.
Preview with dry-run
Show planned files, feature counts, sizes, warnings, and conflicts without creating anything:
geosplit split world.geojson --features 1000 --dry-run
Dry-run still reads and validates the complete input.
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. GeoSplit preserves top-level metadata except bbox, which would no longer describe each split collection. Interrupted transactions are recovered on the next run.
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.
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.4.3.tar.gz.
File metadata
- Download URL: geosplit-0.4.3.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c95cd49ef87100b6efa376c432c97e8049167bdfc6e89bf792c2a168afb71894
|
|
| MD5 |
dd2f9703502792eb19b56bc2f7cf61f0
|
|
| BLAKE2b-256 |
91921d72af58248b3fe5f9cbe406ceed89fd37de0620c4f76adb028fdb19b5da
|
Provenance
The following attestation bundles were made for geosplit-0.4.3.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.3.tar.gz -
Subject digest:
c95cd49ef87100b6efa376c432c97e8049167bdfc6e89bf792c2a168afb71894 - Sigstore transparency entry: 2078697519
- Sigstore integration time:
-
Permalink:
KoaOkano/GeoSplit@8c8e63c5d84c20f987eb266ad91e46a04743250c -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/KoaOkano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8c8e63c5d84c20f987eb266ad91e46a04743250c -
Trigger Event:
release
-
Statement type:
File details
Details for the file geosplit-0.4.3-py3-none-any.whl.
File metadata
- Download URL: geosplit-0.4.3-py3-none-any.whl
- Upload date:
- Size: 14.0 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 |
9100d307032e67861355d72539a06916115fa6a6f5f533884d776416f907c3aa
|
|
| MD5 |
88c1663b022ebf48685aa9562b2f08ee
|
|
| BLAKE2b-256 |
57df2372aa1dbfa5a51a4fd7bc410832887fa67c7aa6ade4ddcd51ca41614c31
|
Provenance
The following attestation bundles were made for geosplit-0.4.3-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.3-py3-none-any.whl -
Subject digest:
9100d307032e67861355d72539a06916115fa6a6f5f533884d776416f907c3aa - Sigstore transparency entry: 2078697672
- Sigstore integration time:
-
Permalink:
KoaOkano/GeoSplit@8c8e63c5d84c20f987eb266ad91e46a04743250c -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/KoaOkano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8c8e63c5d84c20f987eb266ad91e46a04743250c -
Trigger Event:
release
-
Statement type: