Skip to main content
2 of 2
added 1225 characters in body

Remove a raster from Geopackage?

I'm a beginner in the world of geopackages.
I learnd from here and here how to use gdal_translate (and gdaladdo) to import rasters in an existing geopackage or to create a new one. Works fine! But how can I remove one raster that I don't want anymore in the dataset?

Edit after applying method described in user30184's answer: (I quote with copy-paste)
Step 1

$ ogrinfo -sql "drop table new_table" 20170831_Expertise_Elia_Gblx-Auvl.gpkg

INFO: Open of '20170831_Expertise_Elia_Gblx-Auvl.gpkg'
using driver `GPKG' successful.

Step 2

$ ogrinfo -sql "delete from gpkg_contents where table_name='new_table'" 20170831_Expertise_Elia_Gblx-Auvl.gpkg

INFO: Open of '20170831_Expertise_Elia_Gblx-Auvl.gpkg'
using driver `GPKG' successful.

Step 3

$ ogrinfo -sql "delete from gpkg_metadata_reference where table_name='new_table'" 20170831_Expertise_Elia_Gblx-Auvl.gpkg --config OGR_GPKG_FOREIGN_KEY_CHECK OFF

ERROR 1: bad result for PRAGMA foreign_key_check, got 11 rows, expected 0
ERROR 1: pragma foreign_key_check on '20170831_Expertise_Elia_Gblx-Auvl.gpkg' failed
ERROR 1: bad result for PRAGMA foreign_key_check, got 11 rows, expected 0
ERROR 1: pragma foreign_key_check on '20170831_Expertise_Elia_Gblx-Auvl.gpkg' failed
FAILURE:
Unable to open datasource `20170831_Expertise_Elia_Gblx-Auvl.gpkg' with the following drivers.
-> PCIDSK
-> netCDF
-> etc...

=> At 3rd step it went wrong...