Skip to content

Instantly share code, notes, and snippets.

@mikaelhg
Last active December 15, 2025 01:36
Show Gist options
  • Select an option

  • Save mikaelhg/0df898a1801238d112ac6e1d0beabd33 to your computer and use it in GitHub Desktop.

Select an option

Save mikaelhg/0df898a1801238d112ac6e1d0beabd33 to your computer and use it in GitHub Desktop.
Convert Natural Places SHP to geoparquet
#!/bin/bash
function gdal() {
docker run -i --rm -u $(id -u):$(id -g) \
-v "$(pwd)":/app \
-w /app \
ghcr.io/osgeo/gdal:alpine-normal-latest \
"$@"
}
# Convert Natural Places SHP to geoparquet
gdal ogr2ogr -f geojson ne_10m_populated_places.geojson \
'/vsizip//vsicurl?referer=https://www.naturalearthdata.com/&url=https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip'
gdal ogr2ogr -f parquet -lco COMPRESSION=ZSTD ne_10m_populated_places.geoparquet ne_10m_populated_places.geojson
gdal ogr2ogr -f GeoJSON cities.geojson ne_10m_populated_places.geojson \
-lco RFC7946=YES \
-dialect SQLite \
-sql "SELECT SOV0NAME, NAME_EN, WIKIDATAID, GEONAMESID, TIMEZONE, geometry FROM ne_10m_populated_places WHERE POP_MAX > 100000"
gdal ogr2ogr -f parquet -lco COMPRESSION=ZSTD cities.geoparquet cities.geojson
# Compress
zstd -T0 -fk -19 cities.geojson ne_10m_populated_places.geojson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment