[gdal-dev] Working with GeoPackage using python API
Even Rouault
even.rouault at spatialys.com
Wed Sep 5 01:01:24 PDT 2018
Ben,
> Hello, I'm trying to use GDAL python API to work with geopackage files, and
> I ran into some trouble
>
> First off, when creating a geopackage raster, the created raster is always
> 4-bands.
There is no concept of bands in GeoPackage. The raster code for visualization
(the tile gridded coverage data extension, triggered if you create a non-Byte
dataset, is more for analytics but limited to 1-band coverages). So you could
have a mix of tiles with just one band (and a color table), RGB, RGBA, etc.
The driver goes on the safe side on reading and always expose a RGBA dataset.
> Second, the API has no mention as to how to work with the geopackage
> to save/load multiple raster layers and vector layers simultaneously.
>
Multiple raster layers can be added by using the APPEND_SUBDATASET=YES
creation option. See
https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/gpkg.py#L1254
For multiple vector layers, this is just a matter of calling CreateLayer() as
many times as needed, as for all other vector drivers
https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/gpkg.py#L3685 for
examples adds a vector layer to a dataset with a pre-existing raster layer.
(You don't need to play with CREATE_GEOMETRY_COLUMNS or the ExecuteSQL().
Those are just for the purpose of testing the correct behaviour of the driver)
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list