Skip to main content

Split and validate GeoJSON, and convert GeoJSON to and from GeoPackage

Project description

GeoSplit

GeoSplit safely validates GeoJSON and splits a 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
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

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.

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.

Update

python -m pip install --upgrade geosplit

Contributing and security

See CONTRIBUTING.md and SECURITY.md.

License

MIT

Project details


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.5.0.tar.gz (22.0 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.5.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for geosplit-0.5.0.tar.gz
Algorithm Hash digest
SHA256 180685899ff967265bd1466ff21564a4389781e41104620d40a63ef601b1d8bf
MD5 50f5e5809ef5ee37b5a8739629efafa9
BLAKE2b-256 af5fa118b0296df57b670e1b224dca855e3724301ad7d4ceba2924725daea7c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for geosplit-0.5.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.5.0-py3-none-any.whl.

File metadata

  • Download URL: geosplit-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 17.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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2eb9ec88762c10b1ff474b00c8439ac12617340fad5c30972f3ff776a17cf65d
MD5 5fcb6ec42cf32c3d9083843423832ba0
BLAKE2b-256 e86ca541094ba1b8ab91e95858e0626300b1f142f10a9282e2a4617bcd782f4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for geosplit-0.5.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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page