Hi Thanks,<div><br></div><div>My requirement is to run GRASS commands outside GRASS with Python 2.7.3 installed in Windows 7 machine with</div><div>OGR Python bindings. According to sources, there are two possible ways to connect to GRASS data through external Python.</div>
<div>The first method is described in <a href="http://grasswiki.osgeo.org/wiki/GRASS_and_Python">http://grasswiki.osgeo.org/wiki/GRASS_and_Python</a>. However when i set the environment variables in my machine according to above wiki, I cannot connect to GRASS 6.4.3 with Python 2.7.3. When i use following </div>
<div>two imports:</div><div>>> import os, sys</div><div>>></div><div>>> From grass.lib import grass</div><div>>></div><div><br></div><div>For the second one, it gives an error message saying "No module named grass.lib"</div>
<div><br></div><div>Then using the second method, i tried to connect to GRASS with GDAL/OGR grass support. For this i needed to have gdal_grass plugin installed with GRASS. So i compiled GRASS and gdal_grass with OSGEO4W. The stable release of</div>
<div>GRASS 6 in OSGEO4W uses gdal 1.9 and the gdal_grass plugin for latest version is not available in OSGEO4W. The only available plugins are for gdal 1.5 and 1.6 versions under OBSOLETE category of OSGEO4W. I installed both of these and checked GDAL/OGR GRASS support is available within GRASS by typing at GRASS command shell the following:</div>
<div><br></div><div>ogrinfo --formats</div><div>gdalinfo --formats</div><div><br></div><div>But i cannot find gdal_grass support over there. Had it been there i could have read GRASS data as explained by the following code provided my Python has OGR python bindings:</div>
<div><br></div><div><pre><code>from osgeo import ogr
ds = ogr.Open('D:/UEL/GrassGISDB/SLD99/LBS/vector/CluterCleaned/head')
layer = ds.GetLayer(0)
<br></code></pre><pre><code><span style="font-family:arial;white-space:normal">However when i execute above this is the error i get because of the non-availability of gdal_grass plug-in</span></code></pre><pre><code>
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
layer = ds.GetLayer(0)
AttributeError: 'NoneType' object has no attribute 'GetLayer'</code></pre><pre><code><br></code></pre></div><div><pre class="de1"><pre><code><span style="font-family:arial;white-space:normal">The PyGRASS module you have mentioned is a good candidate for working with/ accessing GRASS. However, to</span></code></pre>
<pre><code><span style="font-family:arial;white-space:normal">me i need to access GRASS with external Python and not in the Python shell given in GRASS itself. Is it possible</span></code></pre><pre><code><span style="font-family:arial;white-space:normal">to install PyGRASS module for Python 2.7 in windows like installing numpy or matplotlib modules separate? I hope</span></code></pre>
<pre><font face="arial"><span style="white-space:normal">you understand my question better.</span></font></pre><pre><font face="arial"><span style="white-space:normal">Cheers, Brian.</span></font></pre></pre><br><div class="gmail_quote">
On Tue, Jan 1, 2013 at 8:53 AM, Rashad M <span dir="ltr"><<a href="mailto:mohammedrashadkm@gmail.com" target="_blank">mohammedrashadkm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Did you tried new grass python API?. Before that could you tell what error you are getting?<div><br></div><div>[0] <a href="http://code.google.com/p/pygrass/" target="_blank">http://code.google.com/p/pygrass/</a></div>
<div>
[1] <a href="http://www.ing.unitn.it/~zambelli/projects/pygrass/" target="_blank">http://www.ing.unitn.it/~zambelli/projects/pygrass/</a></div></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">
On Mon, Dec 31, 2012 at 7:14 PM, Brian Sanjeewa Rupasinghe <span dir="ltr"><<a href="mailto:jinkabs@gmail.com" target="_blank">jinkabs@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<div><br></div><div>Actually my requirement is to run Python script outside GRASS Python shell. For this i tried connecting to GRASS outside with Python following the GRASS-wiki instructions, but failed. Then i tried to connect to GRASS with OGR Python bindings, it too failed because gdal_grass plugin provided in OSGEO4W does not install in GRASS (they are considered obsolete in OSGEO4W). However i installed gdal1.6_grass with stable release of GRASS 6.4.3 (run with gdal latest version 1.9.x) in OSGEO4W. However, when checked for the installed packages, gdal_grass support is not provided. It is highly appreciated if it is included in the current OSGEO4W setup or any suggestion.</div>
<div><br></div><div>Cheers, Brian<br><br><div class="gmail_quote">On Sun, Dec 30, 2012 at 1:30 AM, <span dir="ltr"><<a href="mailto:grass-dev-request@lists.osgeo.org" target="_blank">grass-dev-request@lists.osgeo.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send grass-dev mailing list submissions to<br>
<a href="mailto:grass-dev@lists.osgeo.org" target="_blank">grass-dev@lists.osgeo.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:grass-dev-request@lists.osgeo.org" target="_blank">grass-dev-request@lists.osgeo.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:grass-dev-owner@lists.osgeo.org" target="_blank">grass-dev-owner@lists.osgeo.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of grass-dev digest..."<br>
<br>Today's Topics:<br>
<br>
1. Re: GRASS Vector Support (J?rgen E. Fischer)<br>
2. Re: Grass7 GUI compilation failed (Rashad M)<br>
<br><br>---------- Forwarded message ----------<br>From: "Jürgen E." Fischer <<a href="mailto:jef@norbit.de" target="_blank">jef@norbit.de</a>><br>To: <a href="mailto:grass-dev@lists.osgeo.org" target="_blank">grass-dev@lists.osgeo.org</a><br>
Cc: <br>Date: Sat, 29 Dec 2012 17:42:00 +0100<br>Subject: Re: [GRASS-dev] GRASS Vector Support<br>Hi Brian,<br>
<br>
On Sat, 29. Dec 2012 at 10:58:19 +0530, Brian Sanjeewa Rupasinghe wrote:<br>
> I need to automate some GRASS functions in my research work. If there is a<br>
> possibility to build gdal_grass plugin for Windows it is highly<br>
> appreciated. Even the Python scripts that call GRASS functions from<br>
> outside for MS_Windows do not connect with GRASS even though the<br>
> instructions provided in the GRASS wiki is followed. I have posted this<br>
> problem in grass-windows forum and finally advised me to bring the problem<br>
> down to grass-dev list.<br>
<br>
And you are positive that the GDAL plugin would help? The above description<br>
sounds like a more general problem and I don't see any connection to the<br>
missing plugin at all.<br>
<br>
Does GRASS itself need the GDAL GRASS plugin at all?<br>
<br>
<br>
Jürgen<br>
<br>
--<br>
Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-31<br>
Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50<br>
Software Engineer D-26506 Norden <a href="http://www.norbit.de" target="_blank">http://www.norbit.de</a><br>
committ(ed|ing) to Quantum GIS IRC: jef on FreeNode<br>
<br>
--<br>
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH<br>
Rheinstrasse 13, 26506 Norden<br>
GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502<br>
<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Rashad M <<a href="mailto:mohammedrashadkm@gmail.com" target="_blank">mohammedrashadkm@gmail.com</a>><br>To: <a href="mailto:grass-dev@lists.osgeo.org" target="_blank">grass-dev@lists.osgeo.org</a><br>
Cc: <br>Date: Sat, 29 Dec 2012 23:55:17 +0530<br>Subject: Re: [GRASS-dev] Grass7 GUI compilation failed<br><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">here is output from v.digit</span><div style="font-family:arial,sans-serif;font-size:13px">
make</div><div style="font-family:arial,sans-serif;font-size:13px">
<div>ml</div><div>make[6]: Entering directory `/code/grass/grass70/gui/wxpython/vdigit'</div><div>GISRC=/code/grass/grass70/dist.x86_64-unknown-linux-gnu/demolocation/.grassrc70 GISBASE=/code/grass/grass70/dist.x86_64-unknown-linux-gnu PATH="/code/grass/grass70/dist.x86_64-unknown-linux-gnu/bin:/code/grass/grass70/dist.x86_64-unknown-linux-gnu/bin:$PATH" PYTHONPATH="/code/grass/grass70/dist.x86_64-unknown-linux-gnu/etc/python:/code/grass/grass70/dist.x86_64-unknown-linux-gnu/etc/python:$PYTHONPATH" LD_LIBRARY_PATH="/code/grass/grass70/dist.x86_64-unknown-linux-gnu/bin:/code/grass/grass70/dist.x86_64-unknown-linux-gnu/lib:/code/grass/grass70/dist.x86_64-unknown-linux-gnu/lib:" LC_ALL=C /code/grass/grass70/dist.x86_64-unknown-linux-gnu/scripts/g.gui.vdigit --html-description < /dev/null | grep -v '</body>\|</html>' > g.gui.vdigit.tmp.html</div>
<div>Traceback (most recent call last):</div><div> File "/code/grass/grass70/dist.x86_64-unknown-linux-gnu/scripts/g.gui.vdigit", line 39, in <module></div><div> import wx</div><div>ImportError: No module named wx</div>
<div>make[6]: *** [g.gui.vdigit.tmp.html] Error 1</div><div>rm g.gui.vdigit.tmp.html</div><div>make[6]: Leaving directory `/code/grass/grass70/gui/wxpython/vdigit'</div><div>make[5]: *** [guiscript] Error 2</div></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 29, 2012 at 9:57 PM, Rashad M <span dir="ltr"><<a href="mailto:mohammedrashadkm@gmail.com" target="_blank">mohammedrashadkm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">grass7.0 fails compilation at first and continues only after setting PYTHONPATH.<div><br></div><div>This becomes a routine for recompilation. Is there any work around to automatically pickup wxPython?</div>
<div>
<br></div><div>Here is my error log:<br clear="all"><div><br></div><div><div>Started compilation: Sat Dec 29 21:46:17 IST 2012</div><div>--</div><div>Errors in:</div><div>/code/grass/grass70/gui/wxpython/animation</div><div>
/code/grass/grass70/gui/wxpython/mapswipe</div><div>/code/grass/grass70/gui/wxpython/gmodeler</div><div>/code/grass/grass70/gui/wxpython/rlisetup</div><div>/code/grass/grass70/gui/wxpython/psmap</div><div>/code/grass/grass70/gui/wxpython/dbmgr</div>
<div>/code/grass/grass70/gui/wxpython/vdigit</div><div>--</div><div>In case of errors please change into the directory with error and run 'make'.</div><div>If you get multiple errors, you need to deal with them in the order they</div>
<div>appear in the error log. If you get an error building a library, you will</div><div>also get errors from anything which uses the library.</div><div>--</div><div>Finished compilation: Sat Dec 29 21:53:10 IST 2012</div>
</div><div><br></div><div><br></div><div>wxpython is installed from ubuntu repos. so its in the default path</div><span><font color="#888888"><div><br></div><span><font color="#888888"><div><br></div>-- <br>
<div><font face="arial, helvetica, sans-serif">Regards,<br>
Rashad</font></div>
</font></span></font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><font face="arial, helvetica, sans-serif">Regards,<br> Rashad</font></div>
</font></span></div><span><font color="#888888">
<br>_______________________________________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org" target="_blank">grass-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a><br></font></span></blockquote></div><br></div>
<br>_______________________________________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org" target="_blank">grass-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a><br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br>
<div><font face="arial, helvetica, sans-serif">Regards,<br>
Rashad</font></div>
</font></span></div>
</blockquote></div><br></div>