Skip to content

Instantly share code, notes, and snippets.

@mikaelhg
Last active December 30, 2024 03:42
Show Gist options
  • Save mikaelhg/0df898a1801238d112ac6e1d0beabd33 to your computer and use it in GitHub Desktop.
Save mikaelhg/0df898a1801238d112ac6e1d0beabd33 to your computer and use it in GitHub Desktop.
Convert Natural Places SHP to geoparquet
# Convert Natural Places SHP to geoparquet
docker run -it --rm -u 1000:1000 -v `pwd`:/app -w /app ghcr.io/osgeo/gdal:alpine-normal-latest \
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'
docker run -it --rm -u 1000:1000 -v `pwd`:/app -w /app ghcr.io/osgeo/gdal:alpine-normal-latest \
ogr2ogr -f parquet -lco COMPRESSION=ZSTD ne_10m_populated_places.geoparquet ne_10m_populated_places.geojson
# Filter
jq '
.features |= map(
select(.properties.POP_MAX > 100000) |
.properties |= with_entries(
select(.key | IN("SOV0NAME", "NAME_EN", "WIKIDATAID", "GEONAMESID", "TIMEZONE"))
)
) | del(.features) + {features: .features}
' ne_10m_populated_places.geojson > cities.geojson
zstd -fk -19 cities.geojson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment