It works e.g. with the landuse layer from the North Carolina dataset.
But when I use my own rasters I’m getting errors like the one below:
{{{
r.category.trim input=test@Tata qgis=C:\Processing\test cat.txt
Traceback (most recent call last):
File “C:\Users\alistair\AppData\Roaming\GRASS7\addons/scri
pts/r.category.trim.py”, line 197, in
sys.exit(main(*gs.parser()))
File “C:\Users\alistair\AppData\Roaming\GRASS7\addons/scri
pts/r.category.trim.py”, line 123, in main
CCAT = map(int, CCAT)
ValueError: invalid literal for int() with base 10:
‘24.0862’
}}}
I'm pretty sure that it is an integer raster.
It was made with v.to.rast using an attr column that db.describe confirms
contains integers.
These are the categories:
{{{
r.category map=test@Tata
24 cat2
46 cat1
}}}
And if I load the raster into QGIS it describes it the same as the NC
landuse i.e. "Thirty two bit signed integer", and "No data value" =
-2147483648
Hi Alister, I can't find the problem; I also tried some of my own raster
layers without problems. Would it be possible to send a small test raster
layer so I can try out what goes wrong?
I see where the problem lies. When converting a vector layer to raster, it
gets assigned a gradient color table. With your example file, run
r.colors.out.
I.a.w., the categories in the color table are continuous. I would expect
that in case the values in the column used as categories in v.to.rast are
integer, the color table should be set accordingly. But as that is
evidently not the case now, I can try to find a workaround.
For now, you can either create a RGB column in the vector layer and use
that to assign colors (see v.to.rast) or set the colors using r.colors
using color rules or the interactive tool to set colors.
I'm not sure how you meant to reinstall the addon though - using
g.extension in the grass gui just reinstalls the old version, so I had to
manually get the changes from https://trac.osgeo.org/grass/changeset?reponame=&new=72994%40grass-
addons%2Fgrass7%2Fraster%2Fr.category.trim%2Fr.category.trim.py&old=70756
%40grass-addons%2Fgrass7%2Fraster%2Fr.category.trim%2Fr.category.trim.py.
Replying to [comment:5 Alister]:
> Yes it works now, thanks.
>
> I'm not sure how you meant to reinstall the addon though - using
g.extension in the grass gui just reinstalls the old version, [...]
FYI: Since you are on Windows g.extension fetches addons which are
generated daily (but not in real time) on the Windows-build host. This
happens AFAIK once a day, so give it a 24s to show up online. (in your
case here fine that you downloaded the update directly from trac since it
is the addon is written in Python not requiring true compilation).