Opened 18 years ago

Closed 13 years ago

Last modified 13 years ago

#999 closed enhancement (fixed)

added ability to write Raster Attribute Tables to hfa format

Reported by: robert.denham@… Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: GDAL_Raster Version: unspecified
Severity: minor Keywords: HFA
Cc: Markus Neteler

Description (last modified by rdenham)

Modified hfadataset.cpp so that it is possible to write a RAT to an HFA image. 
The function WriteNamedRAT does the work, and is based on ReadNamedRAT.

You can now use:
to save a rat to an HFA images.

Frank there are a couple of things that we weren't sure about in the behaviour
of this.  For example, if you create 2 RAT's, and call 


then in the image the rats are concatenated, rather than rat2 overwriting rat1.
 We weren't sure whether this is what would be expected, but it seemed more
difficult to remove a RAT so we left it.  

GDALRATInitializeFromColorTable also produced some results that might be
unexpected.  If you use GDALRATInitializeFromColorTable to set up the rat, then
save it to an image with a colour table, when looking at the RAT from Imagine
you will see duplicate columns for each colour.  It seems that Imagine
automatically concatenates the colour table to the RAT.

One final thing, is there any chance of python bindings for the RAT stuff?


Attachments (3)

hfadataset.cpp.patch (6.4 KB ) - added by robert.denham@… 18 years ago.
patch for hfdataset.cpp to allow writing of RAT's
hfadataset.cpp.1.7.3.patch (8.4 KB ) - added by rdenham 13 years ago.
Patch to add ability to create raster attribute tables for HFA format. Updated for 1.7.3
hfadataset.cpp.1.8.0.patch (8.4 KB ) - added by Sam Gillingham 13 years ago.
Updated for GDAL 1.8.0

Download all attachments as: .zip

Change History (8)

by robert.denham@…, 18 years ago

Attachment: hfadataset.cpp.patch added

patch for hfdataset.cpp to allow writing of RAT's

by rdenham, 13 years ago

Attachment: hfadataset.cpp.1.7.3.patch added

Patch to add ability to create raster attribute tables for HFA format. Updated for 1.7.3

comment:1 by rdenham, 13 years ago

Description: modified (diff)

by Sam Gillingham, 13 years ago

Attachment: hfadataset.cpp.1.8.0.patch added

Updated for GDAL 1.8.0

comment:2 by Sam Gillingham, 13 years ago

This patch has been used operationally for approx. 5 years by the Queensland Dept. of Environment and Resource Management (Australia) without any problems. We are pretty keen to get this accepted into the mainline and would appreciate any suggestions to help us do so.

We note that the IDRISI driver also supports writing of RATs and the Python bindings for this functionality also exist.

The issues mentioned in the original report we think are reasonable limitations given the HFA implementation of RAT's and Imagine's treatment of them.

Any thoughts on what needs to be done to this patch to have it accepted?

comment:3 by warmerdam, 13 years ago

Keywords: HFA added
Milestone: 1.9.0
Priority: highnormal
Status: newassigned


I'm a reviewing and will apply it in trunk unless I run into serious problems.

comment:4 by warmerdam, 13 years ago

Resolution: fixed
Status: assignedclosed

I have applied the patch in trunk (r21657). I note that WriteNamedRAT() does not support writing the unique valued binning function which comes up in the small test case.

Thanks and sorry for the lengthy delay in applying this patch. I'm very chicken about changes to the hfa driver.

comment:5 by Even Rouault, 13 years ago

r21658 /trunk/gdal/frmts/hfa/hfadataset.cpp: fix memory leak (#999)

Note: See TracTickets for help on using tickets.