Is there a way to use the gdal_contour utility with-in the python console of qgis ? Thank you
|
Renaud, if you are looking to just make contours and not specifically via the console, look to Nathan W's blog post on the core GdalTools plugin currently available in QGIS: Generating contours using GDAL ( via shell or QGIS) If you are looking to generate contours via a Python script or PyQGIS plugin, look to these resources: GdalTools Plugin (QGIS source)/python/plugins/GdalTools/tools/GdalTools_utils.py for functions for finding the gdal binaries and setting up environmental variables. (QGIS source)/python/plugins/GdalTools/tools/doContour.py for how the user interface for the plugin could be manipulated via Python. You would first trigger() the Raster->Extraction->Contour menu's QAction, then manipulate the shown dialog, eventually clicking OK to start the generation of contours. Doing the same as GdalTools in a script/plugin will leverage Python's subprocess module or Qt's QProcess class. Both are used to run an external process, such as gdal_contour in this case. Python Binding svn.osgeo.org/gdal/trunk/autotest/alg/contour.py for how the gdal test suite tests the osgeo.gdal.ContourGenerate() Python binding, which can be used directly in Python code instead of using Python to run the gdal_contours binary. C public callable GDALContourGenerate(), as a reference when using the above Python binding. Attempting to generate contours just via the Python console in QGIS would probably be more laborious than writing a script/plugin to do so. If you really need to use the console, Python's subprocess module would probably be the fastest means. |
|||||||||
|