<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
The variable to increment should be of course as corrected below:<br>
<blockquote type="cite"
cite="mid:143e55a1-1c96-c600-ef1f-df398d068abe@comhem.se">
<br>
# get the unique classes
<br>
<br>
SELECT distinct(label) FROM table;
<br>
<br>
-> fetch results in an array "txt_label"
<br>
<br>
# iterate over array and insert new integer labels in table
<br>
<br>
<b>int_label = 0
</b><br>
<br>
foreach txt_label {
<br>
<br>
INSERT INTO table.label_int VALUES int_label WHERE label =
'txt_label'
<br>
<br>
<b>int_label++</b><br>
<br>
}
<br>
<br>
<br>
/H.<br>
<br>
<br>
<br>
<br>
<br>
On 2019-12-04 18:11, Markus Neteler wrote:
<br>
<blockquote type="cite">Hi,
<br>
<br>
I have a landuse map with text labels (forest, street, ...). For
<br>
r.learn.ml I need to have them as numeric classes.
<br>
It is not important for me which number is assigned but I search
for
<br>
an automated solution, i.e. SQL statement unless there is a
different
<br>
way.
<br>
<br>
So:
<br>
<br>
cat|label|label_int
<br>
1|forest|1
<br>
2|forest|1
<br>
3|street|2
<br>
4|forest|1
<br>
5|street|2
<br>
6|urban|3
<br>
...
<br>
<br>
I guess I have done that already some years ago but I can't
remember
<br>
the trick :-)
<br>
<br>
thanks for a hint,
<br>
Markus
<br>
_______________________________________________
<br>
grass-user mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a>
<br>
</blockquote>
_______________________________________________
<br>
grass-user mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
</blockquote>
</body>
</html>