0

How can I convert a GeoPackage file into GeoJSON?

ogr2ogr -f GeoJSON out.json BGRI2021_0706.gpkg

returns

$ ogr2ogr -f GeoJSON out.json BGRI2021_0706.gpkg 
ERROR 1: database disk image is malformed
FAILURE:
Unable to open datasource `BGRI2021_0706.gpkg' with the following drivers.
  -> `FITS'
  -> `PCIDSK'
  -> `netCDF'
  -> `PDS4'
  -> `VICAR'
  -> `JP2OpenJPEG'
  -> `PDF'
  -> `MBTiles'
  -> `BAG'
  -> `EEDA'
  -> `OGCAPI'
  -> `ESRI Shapefile'
  -> `MapInfo File'
  -> `UK .NTF'
  -> `LVBAG'
  -> `OGR_SDTS'
  -> `S57'
  -> `DGN'
  -> `OGR_VRT'
  -> `REC'
  -> `Memory'
  -> `CSV'
  -> `NAS'
  -> `GML'
  -> `GPX'
  -> `LIBKML'
  -> `KML'
  -> `GeoJSON'
  -> `GeoJSONSeq'
  -> `ESRIJSON'
  -> `TopoJSON'
  -> `Interlis 1'
  -> `Interlis 2'
  -> `OGR_GMT'
  -> `GPKG'
  -> `SQLite'
  -> `ODBC'
  -> `WAsP'
  -> `PGeo'
  -> `MSSQLSpatial'
  -> `OGR_OGDI'
  -> `PostgreSQL'
  -> `MySQL'
  -> `OpenFileGDB'
  -> `DXF'
  -> `CAD'
  -> `FlatGeobuf'
  -> `Geoconcept'
  -> `GeoRSS'
  -> `GPSTrackMaker'
  -> `VFK'
  -> `PGDUMP'
  -> `OSM'
  -> `GPSBabel'
  -> `OGR_PDS'
  -> `WFS'
  -> `OAPIF'
  -> `SOSI'
  -> `Geomedia'
  -> `EDIGEO'
  -> `SVG'
  -> `CouchDB'
  -> `Cloudant'
  -> `Idrisi'
  -> `ARCGEN'
  -> `XLS'
  -> `ODS'
  -> `XLSX'
  -> `Elasticsearch'
  -> `Walk'
  -> `Carto'
  -> `AmigoCloud'
  -> `SXF'
  -> `Selafin'
  -> `JML'
  -> `PLSCENES'
  -> `CSW'
  -> `VDV'
  -> `GMLAS'
  -> `MVT'
  -> `NGW'
  -> `MapML'
  -> `TIGER'
  -> `AVCBin'
  -> `AVCE00'
  -> `HTTP'

ogr2ogr supports already GeoPackage

$ ogrinfo --formats | grep GPKG
  GPKG -raster,vector- (rw+vs): GeoPackage

I am using GDAL 3.3.2, released 2021/09/01

2
  • 1
    The error probably means what it says and there is something wrong with your gpkg file. Some suggestions about what to do in stackoverflow.com/questions/5274202/….
    – user30184
    Commented Nov 28, 2022 at 18:46
  • The GeoPKG file was OK, the problem was that QGIS was using it in parallel and apparently ogr2ogr has issues by running in parallel. But I am not fully sure Commented Nov 30, 2022 at 7:31

1 Answer 1

2

It looks like your GPKG file may have got corrupted somehow. Maybe it wasn't closed properly after writing, or something else (could be anything really). As it's a malformed disk image, I am not sure if there is a solution here. Are you able to re-make the file or re-download it from somewhere?

1
  • 1
    The GeoPKG file was OK, the problem was that QGIS was using ogr2ogr in parallel and apparently ogr2ogr has issues by running in parallel. But I am not fully sure is this. I just know that after exiting QGIS, it worked Commented Nov 30, 2022 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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