TransWikia.com

Setting Config Options for GDAL using Python

Geographic Information Systems Asked by mdl518 on April 2, 2021

I am attempting to invoke the "SetConfigOption" function using the GDAL API to tweak GDAL’s default settings to get additional information about GeoTiff. I am specifying the Config Options below in conjunction with the ‘gdalinfo’ command to retrieve information about the vertical coordinate reference system (VERTCRS). Running ‘gdalinfo’ on the GeoTiff as it is does not show the VERTCRS information, but the VERTCRS info. can obtained from the command line by typing/entering these Config Option commands individually before calling ‘gdalinfo’ on the GeoTiff.

Is there a way to use the "subprocess" function to seamlessly get the VERTCRS information?

Below is the code I am using, which prints the ‘gdalinfo’ output but does not capture the VERTCRS information as needed.

from osgeo import gdal, osr, ogr
import subprocess

gdal.SetConfigOption('GTIFF_REPORT_COMPD_CS','TRUE')
gdal.SetConfigOption('DTED_APPLY_PIXEL_IS_POINT', 'TRUE')
gdal.SetConfigOption('GTIFF_POINT_GEO_IGNORE', 'TRUE')
gdal.SetConfigOption('REPORT_COMPD_CS','TRUE')

cmd='gdalinfo C:usersmikelGeoDataDSM.tif'
print(subprocess.check_output(cmd))

2 Answers

Use the API rather than starting up a subprocess:

gdal.SetConfigOption('GTIFF_REPORT_COMPD_CS', 'YES')
print(gdal.Info(r'C:usersmikelGeoDataDSM.tif'))

Works for me with my data.

Correct answer by user2856 on April 2, 2021

According to the docs, you can use --config to set runtime config options on the command line, e.g.

gdal_translate --config GDAL_CACHEMAX 64 in.tif out.tif

https://gdal.org/user/configoptions.html

Answered by mikewatt on April 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP