Error when writing RAT Column

31 views
Skip to first unread message

William Ray

unread,
Feb 14, 2017, 10:42:29 AM2/14/17
to RSGISLib Support
Hi,

I'm trying to clean up my classification by reclassifying clumps that are surrounded by a class as that class, for instance, building candidates.

I've had no problems calculating the relative border which produces a column with decimals.

However, using this new column to populate the appropriate column is showing an error:

algorithm20160214.py:160: RuntimeWarning: invalid value encountered in greater
  mod_buildings = numpy.where((rel_bor > 0.50), "building_candidate".encode(), mod_buildings)


The relevent bit of code is below:

rastergis.calcRelBorder("pleiades_segs.kea", "rel_bor", "Modern", "building_candidate", False)
rel_bor = rat.readColumn(ratDataset, "rel_bor")
mod_buildings = rat.readColumn(ratDataset, "Modern")
mod_buildings = numpy.where((rel_bor > 0.50), "building_candidate".encode(), mod_buildings)
 
I've checked using tuiview that there are clumps that match this, so that doesn't seem to be the problem.

In addition, I ran the same code specifying: 

numpy.where((mod_buildings == "building_candidate".encode()), "building_candidate".encode(), mod_buildings)

This worked fine.

I suspect it has something to do with the column format but I'm a little confused as I've had no problems with my other RAT columns.

Many Thanks

William 

Nathan Thomas

unread,
Mar 4, 2017, 10:35:40 PM3/4/17
to RSGISLib Support
Hi William,

Does it populate the mod_buildings column ok, even though it gives you a RuntimeWarning?

If so, my guess is that you have a nan value in your rel_bor column which is neither equal to, less than or greater than your 0.5 value. RuntimeWarnings are fairly common in these situations although each should be double checked nevertheless.

Nathan

William Ray

unread,
Mar 30, 2017, 6:59:18 AM3/30/17
to RSGISLib Support
Thanks Nathan,

I have found the solution is to name your classes using numbers. It works fine now that I have done this. I guess it doesn't like strings! 

William
Reply all
Reply to author
Forward
0 new messages