writing columns to RATS

32 views
Skip to first unread message

ciara...@googlemail.com

unread,
Nov 13, 2015, 7:42:57 AM11/13/15
to RSGISLib Support
Hello,

I have a few questions related to writing RAT columns.

When it comes to writing columns to a clumps file attribute table unless I use this  function first on the clumps raster...

populateImageStats(inputImage, clumpsFile, calcMean=True)

.... I am unable to add additional attribute columns from a numpy array. So omitting the line above I get this error when writing to the RAT:

 File "<ipython-input-30-c39e947d62c0>", line 1, in <module>
    rat.writeColumn(ratDataset, 'B1mean', Mn1)

  File "/home/ubuntu/anaconda3/lib/python3.4/site-packages/rios/rat.py", line 330, in writeColumn
    gdalBand = ds.GetRasterBand(bandNumber)

UnboundLocalError: local variable 'ds' referenced before assignment

So I am not interested in the columns produced from the populateImageStats function, but am curious as to why I appear to be unable to write additional columns without first applying this function?

What else is it doing 'under the hood' to the kea file that prepares it for adding columns? Could anyone tell me how I can prepare the kea file for attribute writing without the populateImageStats function?

Many thanks

Ciaran




Daniel Clewley

unread,
Nov 15, 2015, 5:30:01 AM11/15/15
to ciara...@googlemail.com, RSGISLib Support
Hi Ciaran,

You can use the ‘populateStats’ function to add an attribute table to a raster without adding columns with statistics from an image, see http://rsgislib.org/rsgislib_rastergis.html#rsgislib.rastergis.populateStats. With the default options this sets the layer as thematic, creates the RAT and assigns each object a random colour.

How are you creating the clumps file? If you are using ‘runShepherdSegmentation’ to create your clumps file then ‘populateStats’ will be called unless as part of this you have set ‘noStats=False’.

Hope this helps,

Dan

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at http://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages