3

Is there a way to export all layers of a GPKG (Geopackage) database to shapefiles in ONE STEP? Or just a selection? It's a lot of work to export all layers one by one.

  • 4
    Did you try batch processing of the Convert format tool in Processing - GDAL?. – johns Jul 26 at 13:10
3

Not a QGIS solution, but very quick using ogr2ogr with the commandline:

ogr2ogr -f "ESRI Shapefile" output_folder input.gpkg 
2

Download the QPackage Plugin.

When you run this you can select which layers you want saved and it will export them all as shapefiles.

The opposite of this is the Package Layers processing tool which saves everything off as a geopackage.

  • Thank you. Looks like a good plugin. – geopackage80 Jul 29 at 7:30
0

If you want to make it with pythoncode you can use that script from the python console

from osgeo import ogr
source = ogr.Open('d:/tonne/workshop1.gpkg',update=False)
drv = ogr.GetDriverByName( 'ESRI Shapefile' )
for i in source:
    LayerName = i.GetName() 
    inlyr = source.GetLayer( LayerName )
    outds = drv.CreateDataSource( 'd:/tonne/' + LayerName + '.shp')
    outlyr = outds.CopyLayer(inlyr,LayerName)
del inlyr,outlyr,outds  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.