Hi Mohammed,<div><br></div><div>Thanks for your answer. However, when I tried to run your python script I get errors. I run GRASS 6.4.0 on a Mac, downloaded the file <a href="http://wx.path.py">wx.path.py</a>, changed permissions. This is what I get:</div>
<div><br></div><div><div>Welcome to GRASS 6.4.0 (2010) </div><div>GRASS homepage: <a href="http://grass.osgeo.org/">http://grass.osgeo.org/</a></div><div>This version running thru: Bash Shell (/bin/bash)</div>
<div>Help is available with the command: g.manual -i</div><div>See the licence terms with: g.version -c</div><div>Start the GUI with: g.gui wxpython</div><div>When ready to quit enter: exit</div>
<div><br></div><div>GRASS 6.4.0 (spearfish60):~ > ls -l <a href="http://wx.path.py">wx.path.py</a></div><div>-rwxr-xr-x@ 1 robbie staff 12384 18 sep 10:38 <a href="http://wx.path.py">wx.path.py</a></div><div>GRASS 6.4.0 (spearfish60):~ > g.gisenv</div>
<div>GISDBASE=/Users/robbie/grassdata</div><div>LOCATION_NAME=spearfish60</div><div>MAPSET=PERMANENT</div><div>GRASS_GUI=text</div><div>GRASS 6.4.0 (spearfish60):~ > python <a href="http://wx.path.py">wx.path.py</a></div>
<div>Traceback (most recent call last):</div><div> File "<a href="http://wx.path.py">wx.path.py</a>", line 371, in <module></div><div> path_app = PathApp(0)</div><div> File "/Users/Shared/unix/wxpython-snow/lib/python2.6/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 7978, in __init__</div>
<div> File "/Users/Shared/unix/wxpython-snow/lib/python2.6/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 7552, in _BootstrapApp</div><div> File "<a href="http://wx.path.py">wx.path.py</a>", line 361, in OnInit</div>
<div> size=globalvar.MAP_WINDOW_SIZE)</div><div> File "<a href="http://wx.path.py">wx.path.py</a>", line 131, in __init__</div><div> self.AddToolbar(toolb)</div><div> File "<a href="http://wx.path.py">wx.path.py</a>", line 336, in AddToolbar</div>
<div> self.toolbars['map'] = toolbars.MapToolbar(self, self.Map)</div><div> File "/Applications/GRASS-6.4.app/Contents/MacOS/etc/wxpython/gui_modules/toolbars.py", line 165, in __init__</div><div> log = self.parent.gismanager.goutput</div>
<div>AttributeError: 'NoneType' object has no attribute 'goutput'</div></div><div><br></div><div>So, I tried to run an example from <a href="http://grass.osgeo.org/wiki/GRASS_and_Python">http://grass.osgeo.org/wiki/GRASS_and_Python</a>. </div>
<div><br></div><div>I created a new text-file with following code, saved it to regnrowcol.py, changed permissions,... </div><div><br></div><span class="Apple-style-span" style="font-family: monospace; font-size: 10px; "><pre class="de1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: white; border-right-color: white; border-bottom-color: white; border-left-color: white; color: black; background-color: initial; line-height: normal; font: normal normal normal 1em/1.2em monospace; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: top; background-position: initial initial; background-repeat: initial initial; ">
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#!/usr/bin/env python</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#-*- coding:utf-8 -*-</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">############################################################################</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># MODULE: g.region.resolution</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># AUTHOR(S): based on a post at GRASS-USER mailing list [1] </span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># PURPOSE:        Parses "g.region -g", prints out number of rows, cols</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># COPYLEFT: ;-)</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># COMMENT: ...a lot of comments to be easy-to-read for/by beginners</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#############################################################################</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#%Module</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#% description: Print number of rows, cols of current geographic region</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#% keywords: region</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#%end</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># importing required modules</span>
<span class="kw1" style="color: rgb(255, 119, 0); font-weight: bold; ">import</span> <span class="kw3" style="color: rgb(220, 20, 60); ">sys</span> <span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># the sys module [2]</span>
<span class="kw1" style="color: rgb(255, 119, 0); font-weight: bold; ">from</span> grass.<span class="me1" style="color: black; ">script</span> <span class="kw1" style="color: rgb(255, 119, 0); font-weight: bold; ">import</span> core <span class="kw1" style="color: rgb(255, 119, 0); font-weight: bold; ">as</span> grass <span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># the core module [3]</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># information about imported modules can be obtained using the dir() function</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># e.g.: dir(sys)</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># define the "main" function: get number of rows, cols of region</span>
<span class="kw1" style="color: rgb(255, 119, 0); font-weight: bold; ">def</span> main<span class="br0" style="color: black; ">(</span><span class="br0" style="color: black; ">)</span>:
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># #######################################################################</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># the following commented code works but is kept only for learning purposes</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">## assigning the output of the command "g.region -g" in a string called "return_rows_x_cols"</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># return_rows_x_cols = grass.read_command('g.region', flags = 'g')</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">## parsing arguments of interest (rows, cols) in a dictionary named "rows_x_cols"</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># rows_x_cols = grass.parse_key_val(return_rows_x_cols)</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">## selectively print rows, cols from the dictionary "rows_x_cols"</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># print 'rows=%d \ncols=%d' % (int(rows_x_cols['rows']), int(rows_x_cols['cols']))</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># #######################################################################</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># faster/ easier way: use of the "grass.region()" function</span>
gregion = grass.<span class="me1" style="color: black; ">region</span><span class="br0" style="color: black; ">(</span><span class="br0" style="color: black; ">)</span>
rows = gregion<span class="br0" style="color: black; ">[</span><span class="st0" style="color: rgb(72, 61, 139); ">'rows'</span><span class="br0" style="color: black; ">]</span>
cols = gregion<span class="br0" style="color: black; ">[</span><span class="st0" style="color: rgb(72, 61, 139); ">'cols'</span><span class="br0" style="color: black; ">]</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># print rows, cols properly formated </span>
<span class="kw1" style="color: rgb(255, 119, 0); font-weight: bold; ">print</span> <span class="st0" style="color: rgb(72, 61, 139); ">'rows=%d <span class="es0" style="color: rgb(0, 0, 153); font-weight: bold; ">\n</span>cols=%d'</span> <span class="sy0" style="color: rgb(102, 204, 102); ">%</span> <span class="br0" style="color: black; ">(</span>rows, cols<span class="br0" style="color: black; ">)</span>
<span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># this "if" condition instructs execution of code contained in this script, *only* if the script is being executed directly </span>
<span class="kw1" style="color: rgb(255, 119, 0); font-weight: bold; ">if</span> __name__ == <span class="st0" style="color: rgb(72, 61, 139); ">"__main__"</span>: <span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># this allows the script to be used as a module in other scripts or as a standalone script</span>
options, flags = grass.<span class="kw3" style="color: rgb(220, 20, 60); ">parser</span><span class="br0" style="color: black; ">(</span><span class="br0" style="color: black; ">)</span> <span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "># </span>
</pre></span><div><span class="Apple-style-span" style="font-family: monospace; font-size: 10px; line-height: 12px; white-space: pre; "> <span class="kw3" style="color: rgb(220, 20, 60); ">sys</span>.<span class="me1" style="color: black; ">exit</span><span class="br0" style="color: black; ">(</span>main<span class="br0" style="color: black; ">(</span><span class="br0" style="color: black; ">)</span><span class="br0" style="color: black; ">)</span> <span class="co1" style="color: rgb(128, 128, 128); font-style: italic; ">#</span></span></div>
<div><br></div><div><span class="Apple-style-span" style="font-family: monospace; font-size: 10px; line-height: 12px; white-space: pre; "><span class="co1" style="color: rgb(128, 128, 128); font-style: italic; "></span></span>This is also not working:</div>
<div><br></div><div><div>GRASS 6.4.0 (spearfish60):~ > ls -l regnrowcol.py</div><div>-rw-r--r--@ 1 robbie wheel 1839 19 sep 21:01 regnrowcol.py</div><div>GRASS 6.4.0 (spearfish60):~ > chmod a+x regnrowcol.py</div>
<div>GRASS 6.4.0 (spearfish60):~ > ls -l regnrowcol.py</div><div>-rwxr-xr-x@ 1 robbie wheel 1839 19 sep 21:01 regnrowcol.py</div><div>GRASS 6.4.0 (spearfish60):~ > g.region -p</div><div>projection: 1 (UTM)</div><div>
zone: 13</div><div>datum: nad27</div><div>ellipsoid: clark66</div><div>north: 4928000</div><div>south: 4914000</div><div>west: 590000</div><div>east: 609000</div><div>nsres: 100</div>
<div>ewres: 100</div><div>rows: 140</div><div>cols: 190</div><div>cells: 26600</div><div>GRASS 6.4.0 (spearfish60):~ > python regnrowcol.py</div><div>Line too long or missing newline at line 54</div>
</div><div><br></div><div>What can be the problem? Apparently, I'm missing a clue to run python scripts (on my Mac).</div><div><br></div><div>Robbie </div><div><br></div><div><br><br><div class="gmail_quote">2010/9/18 Mohammed Rashad <span dir="ltr"><<a href="mailto:mohammedrashadkm@gmail.com">mohammedrashadkm@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">try<div>wx.path python version.</div><div>but it will not fulfil your needs but more interactive than v.net.path</div>
<div>now it only support spearfish dataset</div><div>will extend to use any data if anyone needs</div><div>
<br></div><div><a href="http://svn.osgeo.org/grass/grass-addons/gui/wxpython/wx.path/wx.path.py" target="_blank">http://svn.osgeo.org/grass/grass-addons/gui/wxpython/wx.path/wx.path.py</a></div><div><br><br><div class="gmail_quote">
<div><div></div><div class="h5">On Fri, Sep 17, 2010 at 7:01 PM, Robbie Heremans <span dir="ltr"><<a href="mailto:robbie.heremans@gmail.com" target="_blank">robbie.heremans@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">Starting from a file with start and end positions (x_start, y_start, x_stop, y_stop) and a vector map of roads, I have to find places on the roads where most people pass, assuming they will use the shortest path or path with the least cost.<div>
<br></div><div>Is there a command in Grass that can do this (ic v.net.path for each record and summary map of these shortest paths)? </div><div><br></div><div>Any suggestions/examples?</div><div><br></div><font color="#888888"><div>
Robbie </div>
</font><br></div></div>_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Rashad<br>
</div>
</blockquote></div><br></div>