<html style="direction: ltr;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body bidimailui-charset-is-forced="true" style="direction: ltr;"
text="#000000" bgcolor="#FFFFFF">
<p>I would do as follows:</p>
<p>(Notice that each street type will become a *separate* raster)<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 11/9/18 1:49 PM, Alessandro
Sebastiani wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CA+4DhS_Cm-r3f_3+AvpbBi0MrabaD_hN3b=d60Js7gjf-LmoBw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Dear all
<div>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:</div>
<div>
<div><b>>>></b>import grass.script as gscript</div>
<div><b>>>></b>types = ("primary" , "secondary" ,
"tertiary" , "service" , "pedestrian" , "footway" ,
"residential" , "path")</div>
<div><b>>>></b>for typ in types:</div>
</div>
</div>
</div>
</div>
</blockquote>
<p> where_str = ("type = %s" % typ)</p>
<p> outrast = "_".join(["type", typ])<br>
</p>
<p> gscript.run_command("v.to.rast",</p>
<p> input = "road_clip", type = "line", where =
where_str,</p>
<p> output = outrast, use="attr", attribute_column =
"cat" )<br>
</p>
<blockquote type="cite"
cite="mid:CA+4DhS_Cm-r3f_3+AvpbBi0MrabaD_hN3b=d60Js7gjf-LmoBw@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div>
<div><b>>>>> </b> gscript.run_command
("v.to.rast" , input = "road_clip" , type = "line" ,
where ="type"=typ , output = types, use = "attr" ,
attribute_column = "cat").</div>
</div>
<div><b>I got the following traceback:</b> File</div>
<div>"/home/alessandro/GRASSDATA/5_citta_def/5_citt_def/.tmp</div>
<div>/alessandro-Lenovo-G50-70/<a href="http://5500.6.py"
moz-do-not-send="true">5500.6.py</a>", line 6</div>
<div> gscript.run_command ("v.to.rast" , input =
"road_clip" ,</div>
<div>type = "line" , where ="type"=typ , output = types, use
=</div>
<div>"attr" , attribute_column = "cat")</div>
<div> ^</div>
<div>SyntaxError: invalid syntax</div>
<div><br>
</div>
<div>i guess the syntax error is in the way i set the query,
but i'm not sure. Thanks to everybody,</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a></pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
</body>
</html>