[Qgis-developer] External calls to SEXTANTE?
Martin Lacayo
mlacayo at stanford.edu
Thu Jun 27 11:07:13 PDT 2013
Hi everyone,
I'm still hoping to get this working. Below is a sample script I would
like, but the GRASS call via SEXTANTE does not produce an output or
raise any errors, although it does print the help for the function.
Any suggestions?
Thank you,
Martin
import sys
import os
sys.path.append("/usr/share/qgis/python/plugins")
sys.path.append(os.getenv("HOME")+"/.qgis/python/plugins")
import PyQt4
import sextante
import qgis
import qgis.utils
def main():
app = PyQt4.QtGui.QApplication(sys.argv)
qgis.core.QgsApplication.setPrefixPath("/usr/lib/qgis", True)
qgis.core.QgsApplication.initQgis()
sextante.core.Sextante.Sextante.initialize()
run_script(qgis.utils.iface)
def run_script(iface):
""" this shall be called from Script Runner"""
sextante.alglist()
sextante.alghelp("grass:r.los")
dem = sys.argv[1]
out_uri = sys.argv[2]
x = sys.argv[3]
y = sys.argv[4]
sextante.runalg("grass:r.los",
input=dem,
coordinate=",".join(x,y),
output=out_uri)
if __name__=="__main__":
main()
On Tue, May 28, 2013 at 2:41 PM, Victor Olaya <volayaf at gmail.com> wrote:
> Definitely that sounds interesting, and I guess that SEXTANTE is a
> right choice for reimplementing your ideas.
>
> about calling algorithms from python, if you are mainly going to use
> GRASS ones, you can probably do it without SEXTANTE, but using
> SEXTANTE will allow you to get more functionality.
>
> I would suggest you to start by writing a simple SEXTANTE algorithm
> that calls the algorithms needed for you model. I could help you on
> that, and then we can see how to maybe take it out of the "normal"
> QGIS/SEXTANTE framework to allow it to be executed without the full
> QGIS GUI (I uderstand that is what you are looking for)
>
> feel free to contact me if you need more help
>
> 2013/5/28 Martin Lacayo <mlacayo at stanford.edu>:
>> Hi Filipe and Victor,
>>
>> Yes, I am part of the software team working on InVEST. I am currently
>> working on transitioning the aesthetic quality (viewshed) model from
>> our 2.0 ArcGIS dependent framework to a 3.0 ArcGIS independent
>> framework. Part of our 3.0 framework is a standalone QT based GUI, for
>> which we hope to enable command line calls (see issue 813 in our
>> repository invest-natcap.googlecode.com) eventually, but it currently
>> set to a medium priority. I understand that once that is working it
>> would be fairly simple to add a wrapper in SEXTANTE, right? There are
>> a lot of factors that go into the development decisions for InVEST, so
>> while I can't say specifically that there is a plan to bring InVEST to
>> QGIS, but the changes we are making should make that very possible.
>>
>> In the meantime, I am faced with the challenge of transitioning the
>> aesthetic quality model away from ArcGIS with the hopes that SEXTANTE
>> can address this and other geoalgorithms needs.
>>
>> Any insight or advice would be much appreciated.
>>
>> Thank you,
>> Martin
>>
>> On Tue, May 28, 2013 at 1:51 PM, Filipe Dias <filipesdias at gmail.com> wrote:
>>> Hi, you are working on InVest right? If so, have you considered making
>>> InVest "inside" Sextante Toolbox? In CC I'm copying Victor Olaya, who is the
>>> main developer of Sextante so he can help with that.
>>>
>>> As a QGIS user it's very exciting for me to know that you are working on
>>> bringing Invest into QGIS.
>>>
>>> Regards
>>> Filipe Dias
>>>
>>>
>>> On Tue, May 28, 2013 at 7:43 PM, Martin Lacayo <mlacayo at stanford.edu> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I would like to make external calls to SEXTANTE with a Python script
>>>> or via the command line. I'm interested in using all the
>>>> geoalgorithms, but in particular I am interested in the GRASS
>>>> geoalgorithms, and specifically in r.viewshed at this moment. Is this
>>>> possible?
>>>>
>>>> I found this post which seems very close to answering the question:
>>>>
>>>>
>>>> http://gis.stackexchange.com/questions/28701/how-to-run-sextante-algorithms-outside-of-qgis-python-console/60725#60725
>>>>
>>>> However when I try calling sextante.runalg I get an error seemingly
>>>> related the fact that the code is not being run inside the QGIS Python
>>>> console (qgis.utils.iface is None).
>>>>
>>>> Our FOSS software (naturalcapitalproject.org) is developed on Linux
>>>> but packaged for Windows. Any suggestions or advice? We are hoping to
>>>> reduce our development time and eliminate duplicated efforts.
>>>>
>>>> Thank you,
>>>> Martin
>>>> _______________________________________________
>>>> Qgis-developer mailing list
>>>> Qgis-developer at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>
>>>
More information about the Qgis-developer
mailing list