7

I am trying to get the raster attribute table of the following file: Shift_cult_past_current_prediction_20160107_gr1DD.tif available here: https://www.dropbox.com/s/fmomfpro3j6dmz8/Shift_cult_past_current_prediction_20160107_gr1DD.tif?dl=0

Here is the code I am using:

import gdal
dataset = gdal.Open(dataset_uri) # dataset_uri is path to .tif file
band = dataset.GetRasterBand(1)
rat = band.GetDefaultRAT()

I am using gdal version 2.1.0 on python 2.7.11 (Mac and windows). However, while I get the raster attribute table on windows I get nothing on mac (10.9.5). What could I be doing wrong?

-- EDIT

$ conda list | grep 'gdal'
gdal                      2.1.0               np111py27_1    conda-forge
9
  • 1
    How did you install GDAL 2.1.0 because I have no problem (Yosemite)
    – gene
    Commented May 4, 2016 at 20:17
  • I just did conda install gdal, not sure what I am missing here
    – user1186
    Commented May 4, 2016 at 20:44
  • updated my question with what I get when I do conda list | grep 'gdal'
    – user1186
    Commented May 4, 2016 at 20:45
  • @gene, does the additional information help?
    – user1186
    Commented May 10, 2016 at 17:21
  • Have you installed QGIS from KyngChaos ? Working with Yosemite, GDAL 2.1 works with Conda Python 3.5, not with Conda Python 2.7.x. In this version I use the GDAL 1.11 of KyngChaos
    – gene
    Commented May 10, 2016 at 19:38

1 Answer 1

0

I downloaded the image that was still there after almost 7 years. That image does not have RAT included at all. It may have be saved into a sidecar file "Shift_cult_past_current_prediction_20160107_gr1DD.tif.aux.xml". I guess that you had is present on Windows but you did not copy that file into Mac. It is also possible to save the RAT inside the TIFF file, but tiffinfo does not show any RAT related tags. Therefore I can only imagine that the aux.xml file has been available at some time.

tiffinfo Shift_cult_past_current_prediction_20160107_gr1DD.tif
TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34736 (0x87b0) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered.
=== TIFF directory 0 ===
TIFF Directory at offset 0x8 (8)
  Image Width: 286 Image Length: 56
  Tile Width: 128 Tile Length: 128
  Bits/Sample: 32
  Sample Format: unsigned integer
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Samples/Pixel: 1
  Planar Configuration: single image plane
  Tag 33550: 1.000000,1.000000,0.000000
  Tag 33922: 0.000000,0.000000,0.000000,-106.000682,29.999417,0.000000
  Tag 34735: 1,1,0,7,1024,0,1,2,1025,0,1,1,2048,0,1,4326,2049,34737,13,0,2054,0,1,9102,2057,34736,1,1,2059,34736,1,0
  Tag 34736: 298.257224,6378137.000000
  Tag 34737: GCS_WGS_1984|
  GDAL NoDataValue: 65536

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.