6

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?

1 Answer 1

7

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
##vectorlayer_inputvector=vector
##rasterlayer_inputraster=raster
##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

9
  • can i save there my model ?
    – hellas
    Commented May 4, 2014 at 12:25
  • The model is saved with the Python script
    – gene
    Commented May 4, 2014 at 13:40
  • 1
    Sadly this doesn't work in 2,6 or 2,8. Does anyone know an alternative method?
    – HC Haase
    Commented Apr 30, 2015 at 8:29
  • @HCHaase - I can confirm that for Windows, QGIS 2.6.1 does still have this function.
    – Joseph
    Commented Apr 30, 2015 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
    Commented Apr 30, 2015 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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