2

I would like to get a list of the values of a GeoTIFF. Is that possible using 'gdalinfo' command? If not, is there any other software that can show that?

1

1 Answer 1

2

Using gdalinfo -stat -hist filename.tif will show accurate min/max/mean/stdev and an histogram:

...

Band 1 Block=3600x1 Type=Int16, ColorInterp=Gray
  Min=109.000 Max=357.000
  Minimum=70.000, Maximum=360.000, Mean=213.611, StdDev=50.093
  256 buckets from 108.514 to 357.486:
  123 20 19 98 245 1215 6146 11234 10651 6540 6686 8793 11477 11133 11302 10019 10024 10427 0 10702 13704 13909 14752 17874 37911 25818 28186 29665 30006 31858 34692 33997 36055 38150 41353 45016 50526 59205 62027 66497 71007 76038 82003 91660 98497 102417 102717 104523 108569 109861 111165 114798 121386 129187 134756 0 134417 128691 120447 116937 113341 107994 104061 96720 92144 90566 90268 90970 90054 88009 87036 87208 84516 83781 81517 83531 84219 82366 76514 74216 73380 73682 77646 81359 81845 79463 78736 79012 79693 79284 79021 0 81866 83499 89131 89123 87721 86717 85787 83111 82528 80375 76604 71097 69147 68075 67551 65979 66586 67808 69705 70972 74056 76805 78348 77754 75459 72178 69727 69044 69695 69193 69304 70659 70731 71463 73156 74464 0 75535 75490 76298 78127 79895 82644 83137 83789 84669 85059 82504 81017 79648 76331 73236 73166 69757 66709 64801 63333 63722 64060 64774 67154 69217 70949 72031 72561 73337 70457 69614 73063 75667 75085 78152 0 82754 84776 80783 76629 72082 69029 69229 66286 64289 61668 59813 57788 53780 48717 42001 37935 35361 32978 32333 32703 30284 29824 29466 28691 28466 28055 27548 27656 27860 26454 26391 24407 23119 22578 22186 0 20772 17948 17690 17787 18111 20116 20464 21493 21413 20502 18666 17492 15892 13740 12641 12227 11266 10181 10409 8853 8386 8935 8311 9531 9492 8612 8361 9086 9253 9286 9602 9555 7951 6776 6220 5971 0 5907 6610 6507 6056 5775 5653 5549 5031 4912 5175 5363 4806 4239 3715 3241 2339 1263 1260
  Metadata:
    STATISTICS_MAXIMUM=360
    STATISTICS_MEAN=213.61135601854
    STATISTICS_MINIMUM=70
    STATISTICS_STDDEV=50.093222321212
    STATISTICS_VALID_PERCENT=100

When there says "N buckets from a to b", it means that on the range from a to b, each of the numbers following is the number of pixels within each equally spaced bin.

i.e.: the above has 123 pixes in with values from 108.5 to 109.5, which on an int16 band is the same to saying that 123 pixels has value 109. then there are 20 pixels with value 110, and so on...

You can easily transform this into a bar chart using your favorite spreadsheet program (or automate it with your favorite shell scripting language)

Edit: individual pixel values

From the comments, i gess you may want individual pixel value extraction.

In case you want a list of individual pixel values, gdal_translate is an option:

>>> gdal_translate -of XYZ "inputfile.tif" tst.xyz

Input file size is 3600, 3600
0...10...20...30...40...50...60...70...80...90...100 - done.

>>> head tst.xyz
-64.999861111111116 -36.0001388888888911 302
-64.9995833333333337 -36.0001388888888911 300
-64.9993055555555515 -36.0001388888888911 298
-64.9990277777777834 -36.0001388888888911 297
-64.9987500000000011 -36.0001388888888911 296
-64.9984722222222189 -36.0001388888888911 295
-64.9981944444444508 -36.0001388888888911 294
-64.9979166666666686 -36.0001388888888911 293
-64.9976388888888863 -36.0001388888888911 293
-64.997361111111104 -36.0001388888888911 292

If raster source is multiband, you can generate individual band files with gdal_translate -b band_number -of xyz ...

columns 1 and 2 are coordinates in the raster CRS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.