How do I run gdal_proximity.py from the QGIS python console?
1 Answer
With the Python processing module (look at Using processing algorithms from the console)
1) look at the Processing Toolbox, there is a proximity command [GDAL] Analysis/proximity:
2) in the Python console
>>> import processing
>>> # list of algorithms (a lot ...)
>>> processing.alglist()
.....
pct2rgb---------------------------------------------->gdalogr:pct2rgb
proximity-------------------------------------------->gdalogr:proximity
rgb2pct---------------------------------------------->gdalogr:rgb2pct
......
>>> processing.alglist('proximity')
Grid proximity buffer-------------------------------->saga:gridproximitybuffer
Proximity grid--------------------------------------->saga:proximitygrid
proximity-------------------------------------------->gdalogr:proximity
and
>>> # help for the parameters of the proximity algorithm
>>> processing.alghelp("gdalogr:proximity")
ALGORITHM: proximity
src_filename <ParameterRaster>
values <ParameterString>
maxdist <ParameterNumber>
nodata <ParameterNumber>
distunits <ParameterSelection>
fixed_buf_val <ParameterNumber>
dst_filename <OutputRaster>
distunits(distunits)
0 - GEO
1 - PIXEL
So you use:
>>> processing.runalg("gdalogr:proximity","your_src_filename",yourvalues,yourmaxdist,yournodata,"GEO",yourfixed_buf_val,"yourdst_filename")
-
alglist()
works okay, but when I try to runlistalgs()
, I get "AttributeError: 'module' object has no attribute 'listalgs'"... Commented Jan 7, 2014 at 15:27