I would do as follows:

(Notice that each street type will become a *separate* raster)


On 11/9/18 1:49 PM, Alessandro Sebastiani wrote:
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:

    where_str = ("type = %s" % typ)

    outrast = "_".join(["type", typ])

    gscript.run_command("v.to.rast",

            input = "road_clip", type = "line", where = where_str,

            output = outrast, use="attr", attribute_column = "cat" )

>>>>    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@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user
-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to