[GRASS-user] Reclassify a vector adding a column

Margherita Di Leo diregola at gmail.com
Wed Jun 17 06:14:41 PDT 2020


Ciao Stefan,

thank you, I tried and it didn't give me any error but didn't update the
column either...

On Wed, Jun 17, 2020 at 12:16 PM Stefan Blumentrath <
Stefan.Blumentrath at nina.no> wrote:

> Ciao Madi,
>
>
>
> You could use db.execute and do something like:
>
> db.execute sql="ALTER TABLE vectormap ADD COLUMN reclass_column TEXT;
>
> UPDATE vectormap SET reclass_column = CASE
>
>      WHEN old_column = ' old value 1' THEN ' new value 1'
>
>      WHEN old_column = ' old value 2' THEN ' new value 2'
>
>      WHEN old_column = ' old value 3' THEN ' new value 3'
>
>      ELSE ' new value 4'
>
> END; "
>
>
>
> Maybe worth adding as an (validated) example to the manual of db.execute (
> https://grass.osgeo.org/grass78/manuals/db.execute.html)…
>
>
>
> Cheers
>
> Stefan
>
>
>
> P.S.: I did not alidate the SQL syntax, but it should be roughly along
> those lines…
>
>
>
> *From:* grass-user <grass-user-bounces at lists.osgeo.org> *On Behalf Of *Margherita
> Di Leo
> *Sent:* onsdag 17. juni 2020 10:35
> *To:* GRASS user list <grass-user at lists.osgeo.org>
> *Subject:* [GRASS-user] Reclassify a vector adding a column
>
>
>
> Hi,
>
>
>
> I need to reclassify a vector in the following way: based on a column of
> type string I have to create a new column of type string based on certain
> rules that I give upon the first column, and I thought it would be really
> handy if I could do it like  CASE WHEN... THEN ...
>
> I have tried to feed a similar rules file to v.reclass but this statement
> is not recognised. How can I translate it? Furthermore, I would like to be
> able to just add a reclass column rather than creating a new vector file,
> is that possible? How?
>
>
>
> Thank you in advance
>
>
>
> Kind regards,
>
>
> --
>
> Margherita Di Leo
>


-- 
Margherita Di Leo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20200617/b416bda8/attachment.html>


More information about the grass-user mailing list