<div dir="auto">Thanks for your answers.<div dir="auto">In fact I need it in Python...</div><div dir="auto"><br></div><div dir="auto">Best</div><div dir="auto">Markus</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Micha Silver <<a href="mailto:tsvibar@gmail.com">tsvibar@gmail.com</a>> schrieb am Mi., 4. Dez. 2019, 18:57:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
    
  
  <div>
    <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:~$ <a href="http://v.info" target="_blank" rel="noreferrer">v.info</a> -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>On 04/12/2019 19:11, Markus Neteler
      wrote:<br>
    </div>
    <blockquote type="cite">
      <pre>Hi,

I have a landuse map with text labels (forest, street, ...). For
<a href="http://r.learn.ml" target="_blank" rel="noreferrer">r.learn.ml</a> 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 href="mailto:grass-user@lists.osgeo.org" target="_blank" rel="noreferrer">grass-user@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank" rel="noreferrer">https://lists.osgeo.org/mailman/listinfo/grass-user</a></pre>
    </blockquote>
    <pre cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
<a href="https://orcid.org/0000-0002-1128-1325" target="_blank" rel="noreferrer">https://orcid.org/0000-0002-1128-1325</a></pre>
  </div>

</blockquote></div>