Geographic Information Systems Asked by Pierrick Rambaud on January 11, 2021
I’m using gdal
lib for Python in a Jupyter Notebook environment.
I’d like to retrieve the resolution of a raster to use it in a gdal.warp call.
At the moment I do the following :
src = gdal.Open(mask)
ulx, xres, xskew, uly, yskew, yres = src.GetGeoTransform()
but I get too much information. Is there a way to only retreive xres
and yres
?
Google says no. But a "workaround" could be to use operator.itemgetter:
import gdal, operator
src = gdal.Open(mask)
xres, yres = operator.itemgetter(1,5)(src.GetGeoTransform())
Correct answer by BERA on January 11, 2021
If you only want to avoid the unused variables use this code:
import gdal
...
src = gdal.Open(mask)
_, xres, _, _, _, yres = src.GetGeoTransform()
Answered by Zoltan on January 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP