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

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


Sorry gdal python version 3.0.2 (not 3.6.0 my mistake)

Em qui., 14 de mai. de 2020 às 10:31, Camila <camila at labsid.eng.br>
escreveu:

> Hi
> 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 =
> creationOptions)
>     outBand = outDs.GetRasterBand(1)
>     outBand.SetNoDataValue(-999)
>     outBand.WriteArray(numpy_array)  # this is where I store my np arrays
>     outDs.SetGeoTransform(trans)
>     ds = None
>     outDs = None
>
> the rows and cols are based on a file I'm using as reference, the output
> type
> 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!
>
>

-- 
*C**amila* *B**illerbeck*
Engenheira Civil
+55 11 3091-5403
+55 11 3091-5549
<camila at labsid.eng.br> <http://www.labsid.eng.br/>
<http://www.youtube.com/labsidengbr>
<https://www.facebook.com/labsid.eng.br>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200514/6fefaded/attachment.html>


More information about the gdal-dev mailing list