I want to automate some tools for QGIS 2.0.2 using Python.

Previously I have used ArcMap for automating tools and now i want to use QGIS.

In ArcMap I used the ModelBuilder, and more specifically the command Export to Python Script to generate Python code from my model.

Now I want to find something similar that will do the same job for my QGIS model i.e. I want to export my model in QGIS to a Python script.

Any ideas?


You can use Save as Python script

enter image description here

The result is a script that you can use in the Toolbox or in the Python console

##Extract raster values (shapefile)=name
##boolean_reprojectvectortorastercrs=boolean false
##output_layer_alg1=output vector
outputs_0=processing.runalg("script:pointsfromvector", rasterlayer_inputraster, vectorlayer_inputvector, None)
outputs_1=processing.runalg("script:extractrastervaluestoshapefile", rasterlayer_inputraster, outputs_0['Output_layer'], boolean_reprojectvectortorastercrs, output_layer_alg1)

enter image description here

  • can i save there my model ?
    – hellas
    May 4 '14 at 12:25
  • The model is saved with the Python script
    – gene
    May 4 '14 at 13:40
  • 1
    Sadly this doesn't work in 2,6 or 2,8. Does anyone know an alternative method?
    – HC Haase
    Apr 30 '15 at 8:29
  • @HCHaase - I can confirm that for Windows, QGIS 2.6.1 does still have this function.
    – Joseph
    Apr 30 '15 at 9:09
  • @HCHaase If you find this does not work at 2.6 and/or 2.8 it would seem like a new question related to that may be needed.
    – PolyGeo
    Apr 30 '15 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.