[GRASS-user] SQL query in python scripts using v.to.rast

st_kiefer at web.de st_kiefer at web.de
Fri Nov 9 04:06:42 PST 2018


Hi Alessandro,
seems you oversaw a typo:

   gscript.run_command ("v.to.rast" , input = "road_clip" , type = "line" , where ="type"=typ , output = types, use = "attr" , attribute_column = "cat")

where ="type"=typ schould rather be  where ="type=%s"%typ

Regards.

Stefan

> Alessandro Sebastiani <alessandro.sebastiani at uniroma1.it> hat am 9. November 2018 um 12:49 geschrieben:
> 
> 
> Dear all
> i have a vector (downloaded from OpenStreetmap) with all the streets in my
> study area. Streets are divided in categories (there is a specific string
> column in the db). now i want to convert to raster each category
> separately. I now how to do that separately, but i was not able to automate
> that in a python script. here it is what i wrote:
> *>>>*import grass.script as gscript
> *>>>*types = ("primary" , "secondary" , "tertiary" , "service" ,
> "pedestrian" , "footway" , "residential" , "path")
> *>>>*for typ in types:
> *>>>> *   gscript.run_command ("v.to.rast" , input = "road_clip" , type =
> "line" , where ="type"=typ , output = types, use = "attr" ,
> attribute_column = "cat").
> *I got the following traceback:*   File
> "/home/alessandro/GRASSDATA/5_citta_def/5_citt_def/.tmp
> /alessandro-Lenovo-G50-70/5500.6.py", line 6
>     gscript.run_command ("v.to.rast" , input = "road_clip" ,
> type = "line" , where ="type"=typ , output = types, use =
> "attr" , attribute_column = "cat")
>                               ^
> SyntaxError: invalid syntax
> 
> i guess the syntax error is in the way i set the query, but i'm not sure.
> Thanks to everybody,
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user


More information about the grass-user mailing list