<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body bidimailui-charset-is-forced="true">
    <p>How about doing this in R? The labels will be read into R as
      factors, and the factor levels can easily be extracted as numbers.</p>
    <p><br>
    </p>
    <p>Something like this:</p>
    <p><br>
    </p>
    <p>micha@tp480:~$ v.info -c stations<br>
      Displaying column types/names for database connection of layer
      <1>:<br>
      INTEGER|cat<br>
      INTEGER|station_num<br>
      TEXT|station_he<br>
      TEXT|station_en<br>
      TEXT|type<br>
      INTEGER|x_coord<br>
      INTEGER|y_coord<br>
      DOUBLE PRECISION|long<br>
      DOUBLE PRECISION|lat<br>
      INTEGER|elev<br>
      TEXT|date_open<br>
      DOUBLE PRECISION|dist<br>
      DOUBLE PRECISION|azim</p>
    <p><br>
    </p>
    <p>micha@tp480:~$ R<br>
    </p>
    <p><br>
    </p>
    <p>R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"<br>
      Copyright (C) 2018 The R Foundation for Statistical Computing<br>
      Platform: x86_64-pc-linux-gnu (64-bit)<br>
      .....<br>
      <br>
      > library(rgrass7)<br>
      Loading required package: XML<br>
      GRASS GIS interface loaded with GRASS version: GRASS 7.6.0 (2019)<br>
      and location: ITM<br>
      > use_sf()<br>
      > stations = readVECT("stations")<br>
      WARNING: Vector map <stations> is 3D. Use format specific
      layer creation<br>
               options (parameter 'lco') to export <in 3D rather than
      2D<br>
               (default).<br>
      Exporting 94 features...<br>
       100%<br>
      .....<br>
    </p>
    <p>> stations['new_station_num'] =
      as.numeric(stations$station_en)<br>
      > stations$new_station_num<br>
       [1] 71 26  6 55 54 63  7  8 31 30 46 84 92 38 32 88 27 12 67 62
      47 33 53 76 89<br>
      [26]  2 86 11 40 65 64 45 13 85 60 59  1 74 73 22 19 15 39 50 56
      14 44 23 36 83<br>
      [51] 41 42 43 18 17 75 16 82 81 37 48 28 87  3 66 10 34 91 61 93
      94 72  5  4 68<br>
      [76] 78 77  9 29 51 58 57 49 52 24 25 80 79 35 70 69 90 21 20<br>
      <br>
    </p>
    <p>> writeVECT(SDF=stations, vname="new_stations")<br>
       <br>
    </p>
    <p>Best regards, Micha</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 04/12/2019 19:11, Markus Neteler
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CALFmHhtaMUe7F4qAUMgdOOy7i5u3Gd3JdLGbLqutgvt0h8Kd_w@mail.gmail.com">
      <pre class="moz-quote-pre" wrap="">Hi,

I have a landuse map with text labels (forest, street, ...). For
r.learn.ml I need to have them as numeric classes.
It is not important for me which number is assigned but I search for
an automated solution, i.e. SQL statement unless there is a different
way.

So:

cat|label|label_int
1|forest|1
2|forest|1
3|street|2
4|forest|1
5|street|2
6|urban|3
...

I guess I have done that already some years ago but I can't remember
the trick :-)

thanks for a hint,
Markus
_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a></pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
<a class="moz-txt-link-freetext" href="https://orcid.org/0000-0002-1128-1325">https://orcid.org/0000-0002-1128-1325</a></pre>
  </body>
</html>