[gdal-dev] Gdal python - gpkg driver creation options

Camila camila at labsid.eng.br
Thu May 14 06:31:41 PDT 2020

This is my first time using the mailing list, I apologize if this question
is out of place.
I am using python 3.6, with gdal python api version 3.6.0

I am working with pcraster framework, and need to store the resulting
simulation files in a geopackage. I found the best way to do this is by
converting the pcr object output to numpy array, and store the numpy array
directly to gpkg file using:

    creationOptions = ['TILE_FORMAT=PNG', 'APPEND_SUBDATASET=YES',
'PRECISION=0', str('RASTER_TABLE='+str(raster_table))]
    outputType= gdal.GDT_Float32
    driver = gdal.GetDriverByName('GPKG')
    outDs = driver.Create(outpath, cols, rows, 1, outputType, options =
    outBand = outDs.GetRasterBand(1)
    outBand.WriteArray(numpy_array)  # this is where I store my np arrays
    ds = None
    outDs = None

the rows and cols are based on a file I'm using as reference, the output
Issues I found:
1) I'm using the option "Tile format = PNG" because I found this option to
be more effective to compress the final output files, I'm working with
about 6000 outputs / Is that actual right, or there is another way to have
tiff files compressed effectively with output data format as Float32?
2) As I said I am working with more than 6000 simulation outputs.. I found
that my final gpkg created file has a limit of 1000 layers... Is that a
default creation option?? How can I make sure my final gpkg file store all
the layers?
3) What is the best way to access a certain via gdal python api the gpkg
layers? Or is best to access the individual layer using sqlite3 lib? I use
the following script to view list the raster tables, but I want to access a
certain layer individually
ds = gdal.OpenEx('my.gpkg')
x = ds.GetMetadata_List('SUBDATASETS')

Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200514/61668a03/attachment-0001.html>

More information about the gdal-dev mailing list