I received a file with 2300 different integer class values in a raster
format. However every one of these 2300 different integer values is
actually a combination of main and subclasses. As I am only interested
in the main classes I used a lookup table to determine how I had to
group the classes according to my interest.
The file was created using the exported sorted values from an exell
sheet, removing the endlines and replacing them with spaces to convert
from a column to a row in text format using
tr -s '\n' ' ' < class1 > temp1
and copy pasting the temp1 files with the '= foo' statement at the end
to the final rules file.
However, this results in a segmentation fault if I run the rule with
r.reclass.file.
Running r.reclass.file on the same raster dataset with an arbitrary rule
1 thru 1000 = 1
1000 thru 2000 = 2
end
does not result in a segmentation fault.
Now I know I use alot of values (2300 of them in the reclass rule) but
could this be the cause of the segmentation fault. Anything I have to
look out for when creating such long rules (new lines, carriage returns
etc etc). Any clues?
I received a file with 2300 different integer class values in a raster
format. However every one of these 2300 different integer values is
actually a combination of main and subclasses. As I am only interested
in the main classes I used a lookup table to determine how I had to
group the classes according to my interest.
However, this results in a segmentation fault if I run the rule with
r.reclass.file.
Now I know I use alot of values (2300 of them in the reclass rule) but
could this be the cause of the segmentation fault. Anything I have to
look out for when creating such long rules (new lines, carriage returns
etc etc). Any clues?
r.reclass appears to have a limit of 100 categories on the LHS of a
rule. Any more than that and it will probably just crash.
You can have multiple rules with the same RHS, so you can just split
each rule into multiple rules, each with less than 100 categories.
It's probably easiest to just make one rule for each category, e.g.:
while read line ; do
lhs="${line%%=*}"
rhs="${line##*=}"
for cat in $lhs ; do
echo $cat = $rhs
done
done < old-rules.txt > new-rules.txt
Indeed if I split up the rules file in with less than 100 categories at
the lhs it works.
Thanks,
Koen
On Tue, 2008-02-26 at 12:33 +0000, Glynn Clements wrote:
Koen Hufkens wrote:
> I have a problem with r.reclass.
>
> I received a file with 2300 different integer class values in a raster
> format. However every one of these 2300 different integer values is
> actually a combination of main and subclasses. As I am only interested
> in the main classes I used a lookup table to determine how I had to
> group the classes according to my interest.
>
> I made r.reclass rules file like:
>
> 1 2 3 6 9 ... 450 123 456 ... = 1
> 3 4 10 ... 325 698 ... = 2
> 11 12 23 54 ... 654 789 222 = 3
> end
> However, this results in a segmentation fault if I run the rule with
> r.reclass.file.
> Now I know I use alot of values (2300 of them in the reclass rule) but
> could this be the cause of the segmentation fault. Anything I have to
> look out for when creating such long rules (new lines, carriage returns
> etc etc). Any clues?
r.reclass appears to have a limit of 100 categories on the LHS of a
rule. Any more than that and it will probably just crash.
You can have multiple rules with the same RHS, so you can just split
each rule into multiple rules, each with less than 100 categories.
It's probably easiest to just make one rule for each category, e.g.:
while read line ; do
lhs="${line%%=*}"
rhs="${line##*=}"
for cat in $lhs ; do
echo $cat = $rhs
done
done < old-rules.txt > new-rules.txt