We have a geoserver instance with Geotiff layers created as layers and mosaics.

When I query the geoserver to getMap as a png or image it displays the correct map data. When I change the output format to geopackage it generates a geopackage that appears correct (I can see the images in SQLite Browser), but when I load the geopackage into any map software (MapCache on Android / http://ngageoint.github.io/geopackage-js/ in Browser) it does not show any map data.

I feel it's an issue with projection of the data, but would that make sense if it correctly shows from the image/png or image/jpeg query?

I have compared my output geopackage to example geopackages and everything seems to look the same (schema/data).

  • Have you tried to open your data QGIS? – user30184 Sep 15 '18 at 9:15
  • Yes, and the same issue occurs. The geopackage contents do not display in the view. When I use the same query (bbox, srs, everything) but with mbtiles as the format, then convert to geopackage (using an online converter), it displays in the web app and QGIS. Seems like a potential geopackage plugin issue. – Justin Howard Sep 15 '18 at 15:52
  • A sample gpkg written by GeoServer would be appreciated. Tell also the version of your GeoServer. – user30184 Sep 15 '18 at 16:03
  • I will include a link to the Geopackage and query shortly.GeoServer Version 2.13.2 Git Revision afacec24a28f35313f7712325be0ff8bc33ac423 Build Date 23-Jul-2018 21:50 GeoTools Version 19.2 (rev 65573d34f5a7da06abb3b793026d4b1c09af616a) GeoWebCache Version 1.13.2 (rev 1.13.x/78018a44f070339647f3c302b868adb5f1b08290) – Justin Howard Sep 15 '18 at 17:18
  • Here is the link to the geopackage (…) And the example query: (…) – Justin Howard Sep 15 '18 at 17:35

The metadata that deals with the tile matrixes in the GeoPackage that you provided are not valid and I suppose I could locate where the problem is.

I used the GeoPackage validator script from the GDAL project from here https://github.com/OSGeo/gdal/blob/master/gdal/swig/python/samples/validate_gpkg.py

The script gives this error:

Req 45: Inconsistent values in gpkg_tile_matrix and gpkg_tile_matrix_set for table M3_002345621_45613

The requirement 45 in the GeoPackage standard is this:

Requirement 45

The width of a tile matrix (the difference between min_x and max_x in gpkg_tile_matrix_set) SHALL equal the product of matrix_width, tile_width, and pixel_x_size for that zoom level. Similarly, height of a tile matrix (the difference between min_y and max_y in gpkg_tile_matrix_set) SHALL equal the product of matrix_height, tile_height, and pixel_y_size for that zoom level.

The gpkg_tile_matrix table MAY contain row records for zoom levels in a tile pyramid user data table that do not contain tiles.

GeoPackages follow the most frequently used conventions of a tile origin at the upper left and a zoom-out-level of 0 for the smallest map scale "whole world" zoom level view [K20], as specified by WMTS [16]. The tile coordinate (0,0) always refers to the tile in the upper left corner of the tile matrix at any zoom level, regardless of the actual availability of that tile.

The (max_x - min_x) in gpkg_tile_matrix_set is about 402 meters.

enter image description here

In the gpkg_tile_matrix table for example zoom level 8 is defined to have 256 horizontal tiles with 256 pixels each and having pixel size of about 611 meters.

enter image description here

402 is not not equal to (256 x 256 x 611) which makes the metadata invalid.

It seems that this open ticket in the GeoServer bugs is about the same issue https://osgeo-org.atlassian.net/browse/GEOS-8262.

You may want to add your comment to the ticket.


Your GeoPackage is created to use the global Web Mercator projection and then there is an easy workaround. The following SQL command sets the bounds of the tile matrix set right and then QGIS can open the GeoPackage raster layer fine.

UPDATE gpkg_tile_matrix_set
SET min_x=-20037508.340000,

You can use any SQLite SQL client you want. Spatialite-gui is one alternative or you can use ogrinfo as a SQLite client from command line:

ogrinfo -sql "update gpkg_tile_matrix_set set min_x=-20037508.340000,min_y=-20037507.852000,max_x=20037507.852000,max_y=20037508.340000" test-mosaic_0.gpkg
  • GeoServer supports reading GeoPackage, that's in core now, but writing them is still not officially supported, the module the reported is not part of releases and has no maintainer. Patches and more importantly someone to fix and maintain that module are more than welcomed! :-) – Andrea Aime Sep 16 '18 at 16:24
  • I am outputting in mbtiles format and using an external converted to geopackage format to workaround the bug for the moment. Thank you for the feedback. – Justin Howard Sep 18 '18 at 22:21

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.