Skip to main content

Convert common geospatial files with one command. Probe inputs, batch convert, and reproject to WGS84 for KML.

Project description

geoconvert

Convert common geospatial files with one command.

GeoJSON hub. KML-ready reprojection. Batch mode. Probe to avoid surprises.

pip install geoconvert-cli
geoconvert parcels.shp parcels.kml

The problem

You have a shapefile from the county. You need KML for Google Earth. Or GeoJSON for your web map. Or CSV for a spreadsheet.

So you either:

  • Fight with GDAL/ogr2ogr flags you'll forget by tomorrow
  • Upload to some website and hope it doesn't mangle your data
  • Open QGIS just to click Export

And then your KML shows up in the middle of the ocean because the shapefile was in State Plane and nobody told you.


The fix

pip install geoconvert
# Single file
geoconvert input.shp output.geojson

# Batch convert a whole directory
geoconvert county_data/ converted/ --to kml

# Check what you're dealing with first
geoconvert --probe mystery_file.shp

That's it. It reads the .prj, reprojects to WGS84 when needed, and tells you when something's wrong instead of silently producing garbage.


What it handles

From To
Shapefile (.shp) GeoJSON
GeoJSON KML (Google Earth)
KML / KMZ CSV (with lat/lon)
GPX (GPS tracks) TopoJSON (for D3)
CSV (with coordinates) SVG (static maps)
TopoJSON WKT (for PostGIS)
Shapefile

Mix and match. Everything goes through GeoJSON internally, so any input works with any output.


What it gets right

Projections. If your shapefile is in UTM or State Plane, it reprojects to WGS84 automatically for formats that need it (like KML). If it can't figure out the CRS, it tells you instead of guessing.

geoconvert --probe parcels.shp

# Output:
# CRS: EPSG:26915 (UTM Zone 15N)
#   Geographic (lat/lon): No (projected)
# Features: 847
# Geometry types: MultiPolygon
#
# Warnings:
#   - CRS is projected. KML output requires reprojection.

Batch mode that doesn't destroy your afternoon. Convert hundreds of files. Skip ones that already exist. Get a JSON report of what worked and what didn't.

geoconvert all_parcels/ output/ --to kml --summary --report results.json

# Found 423 files to convert
# ...
# Batch conversion complete:
#   Succeeded: 421
#   Failed: 2
#   Skipped: 0

Honest about what it drops. KML can have styles, folders, network links, overlays. When you convert to GeoJSON, those go away. --probe tells you upfront.


Use it as a library

from geoconvert import convert, read_shapefile, write_kml, probe

# One-liner
convert("input.shp", "output.geojson")

# Or read, filter, write
geojson = read_shapefile("parcels.shp")
geojson["features"] = [f for f in geojson["features"]
                       if f["properties"]["ACRES"] > 40]
write_kml(geojson, "large_parcels.kml")

# Check a file before converting
info = probe("unknown.kml")
print(info["crs"], info["feature_count"], info["warnings"])

Install

pip install geoconvert-cli

Requires Python 3.9+. Dependencies: pyshp, pyproj.


CLI Reference

geoconvert [options] input... output

Modes:
  geoconvert in.shp out.geojson          Single file conversion
  geoconvert dir/ out/ --to kml          Batch conversion
  geoconvert --probe file.shp            Inspect without converting

Batch options:
  --to EXT              Target format (kml, geojson, csv, etc.)
  --recursive, -r       Process subdirectories
  --include-ext .shp    Only process these extensions
  --overwrite           Replace existing output files
  --summary             Print totals at end
  --report FILE         Save JSON report

CRS options:
  --src-crs EPSG:26915  Override source CRS
  --assume-wgs84        Trust input is already WGS84
  --no-reproject        Skip reprojection (advanced)

Format options:
  --lat COL             Latitude column for CSV input
  --lon COL             Longitude column for CSV input
  --name-field PROP     Property for KML placemark names
  --include-wkt         Add WKT column to CSV output
  --width, --height     SVG dimensions

When to use something else

  • You need industrial-strength format support: Use GDAL/ogr2ogr
  • You need topology preservation: Use TopoJSON CLI
  • You're doing spatial analysis: Use GeoPandas or PostGIS
  • You need a GUI: Use QGIS

geoconvert is for the 80% case: you have files in format A, you need them in format B, and you want it to just work.


What it actually supports

Shapefiles

Works with standard Point, LineString, Polygon, Multi* geometries in WGS84 or any projected CRS with a .prj file. Reads DBF attributes. Field names truncate to 10 characters on output (shapefile limitation).

KML / KMZ

Reads Placemarks with geometry and ExtendedData. KMZ files are auto-extracted. Writes standard Placemarks. Ignores NetworkLinks, GroundOverlays, Styles, and folder hierarchy.

Everything else

  • GeoJSON: Full support (it's the internal format)
  • GPX: Waypoints become Points, tracks become LineStrings
  • CSV: Points only, requires lat/lon columns
  • TopoJSON: Basic arc decoding, no topology optimization on output
  • WKT: Output only, one geometry per line
  • SVG: Output only, simple styling

License

MIT


Built because life's too short to remember ogr2ogr flags.

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

geoconvert_cli-0.1.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

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

geoconvert_cli-0.1.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file geoconvert_cli-0.1.0.tar.gz.

File metadata

  • Download URL: geoconvert_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for geoconvert_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 19be8ba18026c63a9bce86586e9624c157099cdb33f0ea62a7644152624a407d
MD5 c4849fcf85438d5df30530f0ef544fbc
BLAKE2b-256 cc938dff6110a92e3302a8d545b44317634bee154dadd6620a13544af7570d37

See more details on using hashes here.

Provenance

The following attestation bundles were made for geoconvert_cli-0.1.0.tar.gz:

Publisher: publish.yml on switmer/geoconvert-cli

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

File details

Details for the file geoconvert_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: geoconvert_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for geoconvert_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6fec5f50a99c7d6868cd456fa69837aef84a7163eee47791931106a7fdf70b4
MD5 9cac6bc74352bd0c8f37e6d75921bb79
BLAKE2b-256 1196a0bdf61428439859ee33763320453a9949d701c2da37d16c61467938f683

See more details on using hashes here.

Provenance

The following attestation bundles were made for geoconvert_cli-0.1.0-py3-none-any.whl:

Publisher: publish.yml on switmer/geoconvert-cli

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