[GRASS-user] Reclassify a vector adding a column

Margherita Di Leo diregola at gmail.com
Wed Jun 17 09:38:43 PDT 2020


Dear Micha,

On Wed, Jun 17, 2020 at 4:05 PM Micha Silver <tsvibar at gmail.com> wrote:

>
> On 17/06/2020 16:14, Margherita Di Leo wrote:
>
> Ciao Stefan,
>
> thank you, I tried and it didn't give me any error but didn't update the
> column either...
>
>
>
> The sqlite CASE statement should be:
>
> CASE <old_column> WHEN '<old_val1>' THEN '<new_val1>' WHEN '<old_val2>'
> THEN '<new_val2>'....END;
>
>
> Here's an example that worked for me. I have a "myroads" vector with
> column 'TYPE'
>
>
> # Add new column for road width as text
>
> v.db.addcolumn myroads column="width TEXT"
>
> # Run update with CASE
>
> db.execute sql="UPDATE myroads SET width=CASE TYPE WHEN 'Main' THEN 'Wide'
> WHEN 'Local' THEN 'Narrow' ELSE 'Unknown' END;"
>
>
> Best, Micha
>
This worked! Thank you so much! I have one last question. Does it also
support an IS LIKE condition, and if yes, how can I express it?

Thanks!


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


More information about the grass-user mailing list