Hi All
I've made a few scripts which using GDAL extract the value of a pixel within a given raster. The purpose is to work out the combine value of every pixel. I thought there may have been an easier way to do this but alas!
The code below extracts the pixel value at position X Y. The value is a floating point rather than an integer and thats where my problem lies. The if statement simply exports the value to a txt file. Other scripts take care of the rest ie change values of X Y and summing the resultant txt files.
#!/bin/sh
input=`gdallocationinfo -valonly 210_1515_volume.env X Y` # The value of the pixel at coordinate X Y
if [ $input -gt 0 ] ;then
echo $input > colrow.txt
fi
However, I get the following message back when ever my statement is true because my value isn't an integer;
extract2.sh: line 4: [: 2.15787172317505: integer expression expected
Please note the raster file mostly contains zero values, and its only the values greater than zero I'm interested in, which is why I added the expression.
Any ideas how I can alter this code so the IF statement excepts integers? Alternatively if anyone knows of a faster method of quickly summing the values of a raster file, that would be equally useful.
Many thanks in advance for any assistance you can offer.
Andy