Given a .tiff topographic raster image.
How to get the altitudes of the highest and lowest point/pixel ?
Answer
You can use :
gdalinfo -mm input.tif
It returns a range of infos within which is the string Computed Min/Max=-425.000,8771.000
, for my Eurasian raster.
Some cleanup and you get your vertical min/max variables:
$zMin=`gdalinfo -mm ./input.tif | sed -ne 's/.*Computed Min\/Max=//p'| tr -d ' ' | cut -d "," -f 1 | cut -d . -f 1`
$zMax=`gdalinfo -mm ./input.tif | sed -ne 's/.*Computed Min\/Max=//p'| tr -d ' ' | cut -d "," -f 2 | cut -d . -f 1`
$echo $zMin $zMax
>-425 8771
I trimed both the digits after decimal point and the spaces in case via cut -d
and tr -d ' '
, respectively. Adapt as needed.
No comments:
Post a Comment