Skip to content

Instantly share code, notes, and snippets.

@njanakiev
Last active March 9, 2021 19:56
Show Gist options
  • Save njanakiev/1b733068f61f339c570e8c3378ee1e3a to your computer and use it in GitHub Desktop.
Save njanakiev/1b733068f61f339c570e8c3378ee1e3a to your computer and use it in GitHub Desktop.
GDAL and OGR command recipes

GDAL and OGR Recipes

Convert Shapefile to CSV file

ogr2ogr -f "CSV" output.csv input.shp -lco GEOMETRY=AS_XY

Convert Shapefile to GeoJSON

ogr2ogr -f "GeoJSON" output.json input.shp

Extract geometries from Shapefile with Attribute iso_a2 = 'GB'

ogr2ogr -where "iso_a2 = 'GB'" gb.shp input.shp

Previous two commands combined in a single command

ogr2ogr -f GeoJSON -where "iso_a2 = 'GB'" gb.json input.shp

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment