Skip to main content

GeoSplit

PyPI version Python versions License: MIT

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 --force is supplied.
  • --force only 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.

Performance checks

GeoSplit includes a small benchmark runner for development and CI:

python benchmarks/geojson_benchmark.py --features 2000 --operation all --json

See docs/performance.md for the benchmark policy, baseline guidance, and large-run recommendations.

Update

python -m pip install --upgrade geosplit

Contributing and security

See CONTRIBUTING.md and SECURITY.md.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geosplit-0.6.0.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geosplit-0.6.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file geosplit-0.6.0.tar.gz.

File metadata

  • Download URL: geosplit-0.6.0.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for geosplit-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f18f896e0e6bd90066d262e9b22259aa2f717668a288c2d8984b67a5e282a03d
MD5 0900caaffaf2bdfc1430f9189ed0d299
BLAKE2b-256 84d2b82ddb8f1dae0b4ad5e96ee741e94ee518c374d1f136f50b070777a02d02

See more details on using hashes here.

Provenance

The following attestation bundles were made for geosplit-0.6.0.tar.gz:

Publisher: release.yml on KoaOkano/GeoSplit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file geosplit-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: geosplit-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for geosplit-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d150c3d33e438a029b26f98e78b0ed07d5f6f84ad35ba3529ab5c52e4cd6793b
MD5 cc786634faefc1c061f9d8c69e7c4276
BLAKE2b-256 98d4cfc853a9e6621b4642bb739650ec7cf53fb11f76ee1b787139c904edf906

See more details on using hashes here.

Provenance

The following attestation bundles were made for geosplit-0.6.0-py3-none-any.whl:

Publisher: release.yml on KoaOkano/GeoSplit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.7.0

2 files

This release

0.6.0 This release

2 files

0.5.5

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page