OGR2OGR Geopackage (gpkg) and GeoJSON

 How to export GeoPackage (.gpkg) table to GeoJSON file using OGR2OGR


Long story really, really short do this from the command line, terminal, Windows PowerShell what have you.

How to export a single  GeoPackage table to a single GeoJSON file:

ogr2ogr -f GeoJSON -t_srs crs:84 yourtablename.geojson -sql "select * from yourtablename" yourgeopackage.gpkg


Assumptions making this work for you:  
  1. ogr2ogr is installed
  2. you execute this command from within the same folder as the GeoPackage file itself
  3. you want your GeoJSON file output to the current folder


How to export all GeoPackage tables to Shapefiles?

ogr2ogr -f "ESRI Shapefile" yourgeopackage.gpkg

This will export all tables to the current folder where your GeoPackage is located.





Comments

Popular Posts