[GRASS-user] r.viewshed Python Script OSError

Markus Metz markus.metz.giswork at gmail.com
Tue May 28 11:20:58 PDT 2013

On Tue, May 28, 2013 at 7:09 PM, Martin Lacayo <mlacayo at stanford.edu> wrote:
> Hi Markus,
> I did install r.viewshed (it is located in ~/.grass6/addons/), and the
> full path does appear in $PATH.
> I am executing the Python script from outside of GRASS. Is this
> normal? I am hoping for some advice on this.

You need to execute the Python script from within GRASS, or set some
environment variables first, see [1]. Within your script, you could
also first use a dummy location, for example the GRASS demolocation,
then create a new location with the projection information in the
raster map to be used as input for r.viewshed, change to that
location, import the raster map, run r.viewshed, export the result.
This is essentially what the SEXTANTE plugin in QGIS is doing.

> The intent is to liberate
> some software (naturalcapitalproject.org) from ArcGIS for users on
> Windows.


> When I start GRASS (in text mode) it says "Welcome to GRASS 6.4.2 (2012)."

If possible, update to GRASS 6.4.3.


Markus M

[1] http://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly

> Thank you,
> Martin
> On Sun, May 26, 2013 at 1:27 PM, Markus Metz
> <markus.metz.giswork at gmail.com> wrote:
>> On Fri, May 24, 2013 at 11:32 PM, Martin Lacayo <mlacayo at stanford.edu> wrote:
>>> Hello,
>>> I am using GRASS 6.4 on Debian. I am trying to make a call to
>>> r.viewshed from Python, but it fails with the following exception:
>>> OSError: [Errno 2] No such file or directory
>>> Any suggestions?
>> Did you install r.viewshed?
>> Where is the r.viewshed binary?
>> Is the location of r.viewshed in the PATH (within GRASS, test with
>> "echo $PATH")?
>> Did you execute the python script from within GRASS?
>> Which GRASS 6.4 version are you using? Recommended is 6.4.3.svn.
>> Markus M

More information about the grass-user mailing list