[Qgis-user] call grass modules via qgis python console - Sextante plugin

S. Koukoulas (lists) sotkouklistes at gmail.com
Sun Nov 25 11:44:14 PST 2012


great! here is the example that worked fine:

#Example with GRASS (through python console and sextante)
# load the DEM in QGIS
import sextante

# define dem as the active raster layer (PyQGIS documentation provides
alternative examples as well)
dem = qgis.utils.iface.activeLayer()

# optional - if you need to find out the correct syntax

sextante.alghelp("grass:r.slope")


sextante.runalg("grass:r.slope", dem, None, None, 1, 0, 1,
"657062.140513,726286.390884,4315084.44829,4362331.68379", 90,
"\yourfolder\slopegrasstest.tif")

Extent can be found by :
dem.extent().toString()
and the output is given in a Xmin,Ymin:Xmax,Ymax format,
where in the slope algorithm above, you need to input the 
"Xmin,Xmax,Ymin,Ymax" format.

many thanks again,
sotiris

On 11/25/2012 02:44 AM, Salvatore Larosa wrote:
> Hi,
>
> 2012/11/25 S. Koukoulas (lists) <sotkouklistes at gmail.com
> <mailto:sotkouklistes at gmail.com>>
>
>     I am trying to run grass commands through the python console using
>     sextante and following this example:
>
>     example:
>     #import sextante python bindings
>     from sextante.core.Sextante import Sextante
>      
>
>     #search available modules -- all
>     Sextante.alglist()
>
>
> now is enough run:
>
> >>> import sextante ## see link below[1]
>
> and then:
>
> >>> sextante.alglist()
>
> Regards,
>
> -SL
>
>
> [1] -
> http://docs.qgis.org/html/it/docs/user_manual/sextante/console.html#calling-sextante-from-the-python-console
>
>  
>
>
>     but I am getting the following error at Sextante.alglist() ... any
>     help?
>     .....
>     >>> Sextante.alglist()
>
>     Traceback (most recent call last):
>
>     File "<input>", line 1, in <module>
>
>     AttributeError: class Sextante has no attribute 'alglist'
>
>
>     thanks,
>     sotiris
>
>     QGIS 1.8, Sextante 1.0.8
>     OS:  Linux 3.6.6-1.fc17.x86_64 x86_64
>     System:  Fedora release 17 (Beefy Miracle)
>     KDE:  4.9.3
>
>
>
>     On 08/10/2012 07:26 PM, richard burcher wrote:
>     > Hi maning,
>     >
>     > Take a look at Sextante plugin. Can call grass modules from
>     python console
>     > very easily.
>     >
>     > example:
>     > #import sextante python bindings
>     > from sextante.core.Sextante import Sextante
>     >
>     > #search avaible modules -- all
>     > Sextante.alglist()
>     > #search specific
>     > Sextante.alglist("voronoi")
>     > [output] v.voronoi - Creates a Voronoi diagram from an input
>     vector map
>     > containing points or centroids.--->grass:v.voronoi
>     >
>     > #get help on alg inputs
>     > Sextante.alghelp("grass:v.voronoi")
>     > [output] ALGORITHM: v.voronoi - Creates a Voronoi diagram from
>     an input
>     > vector map containing points or centroids.
>     >         input <ParameterVector>
>     >         -l <ParameterBoolean>
>     >         -t <ParameterBoolean>
>     >         GRASS_REGION_PARAMETER <ParameterExtent>
>     >         GRASS_REGION_CELLSIZE_PARAMETER <ParameterNumber>
>     >         output <OutputVector>
>     >
>     > #run algorithm
>     > Sextante.runalg("grass:v.voronoi",[follow from Sextante.alghelp
>     output])
>     >
>     > Use the svn update of Sextante. Checkout my blog post on setting
>     up svn for
>     > this
>     >
>     http://geotechrichard.com/2012/06/08/how-to-keep-pace-with-qgis-sextante-svn-of-course/
>     >
>     > Cheers,
>     >
>     > Richard
>     >
>     >
>     >
>     >
>     > --
>     > View this message in context:
>     http://osgeo-org.1560.n6.nabble.com/call-grass-modules-via-qgis-python-console-tp4994410p4994471.html
>     > Sent from the Quantum GIS - User mailing list archive at Nabble.com.
>     > _______________________________________________
>     > Qgis-user mailing list
>     > Qgis-user at lists.osgeo.org <mailto:Qgis-user at lists.osgeo.org>
>     > http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>     _______________________________________________
>     Qgis-user mailing list
>     Qgis-user at lists.osgeo.org <mailto:Qgis-user at lists.osgeo.org>
>     http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
>
>
> -- 
> Salvatore Larosa
> linkedIn: http://linkedin.com/in/larosasalvatore
> twitter: @lrssvt
> skype: s.larosa
> IRC: lrssvt on freenode
>




More information about the Qgis-user mailing list