[QGIS-Developer] QGIS 3 modeler - GDAL call parameters double escaped

Luigi Pirelli luipir at gmail.com
Wed Jun 13 04:32:58 PDT 2018


should be applied the same fix applied to gdal_calc...
https://github.com/qgis/QGIS/pull/6984

in that case the problem was interpreting the formula as path... in your
case you are escaping a real path

GdalUtils.escapeAndJoin in  getConsoleCommands(...) do escaping...

Luigi Pirelli


**************************************************************************************************
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS 2nd Edition:
*
https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
* Hire me: http://goo.gl/BYRQKg
**************************************************************************************************


On Wed, 13 Jun 2018 at 12:10, Jorge Gustavo Rocha <jgr at di.uminho.pt> wrote:

> Hi,
>
> I was showing a very small use case of the modeler, with just two steps,
> to count reindeers in a IR raster. It failed with a very simple error.
> If I use spaces in the final output name, it fails. This is not a high
> priority issue.
>
> If I set the output name as 'reindeer polygons', the gdal call is:
>
> gdal_polygonize.py
>
> /tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/dfee0e38cbd1483ca732fd82a12110c5/OUTPUT.tif
>
> "\"/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ef043a13ea8044c4a4ab9fee9c373b1f/gdal_polygonize_1_reindeer
> polygons.shp\"" -b 1 -f "ESRI Shapefile"
>
> But the additional " are not necessary and it will fail. The entire log
> is below.
>
> If the generated string was just (without the additional \"):
>
> gdal_polygonize.py
>
> /tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/dfee0e38cbd1483ca732fd82a12110c5/OUTPUT.tif
>
> "/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ef043a13ea8044c4a4ab9fee9c373b1f/gdal_polygonize_1_reindeer
> polygons.shp" -b 1 -f "ESRI Shapefile"
>
> it works.
>
> So, it is escaped only if there are spaces on the output name. In Linux
> this double escaping fails. Does this escaping works on other OS? Is it
> safe to discard this double escaping mechanism?
>
> Regards,
>
> J. Gustavo
> --
> Jorge Gustavo Rocha
> Departamento de Informática
> Universidade do Minho
> 4710-057 Braga
> Tel: +351 253604480
> Fax: +351 253604471
> Móvel: +351 910333888
> skype: nabocudnosor
>
>
> -----------------------------------------------------------------------------------------
>
> Processing algorithm…
> Algorithm 'Counting Reindeer' starting…
> Input parameters:
> { 'gdal:polygonize_1:reindeer polygons' :
>
> '/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ed2a4eb50e1d4a6ebe98392ea9f1c520/gdal_polygonize_1_reindeer
> polygons.shp', 'infrared' :
> '/home/jgr/Documentos/Classification/classification.tif' }
>
> Prepare algorithm: qgis:rastercalculator_1
> Running Raster calculator [1/2]
> Input Parameters:
> { CELLSIZE: 1, CRS: 'EPSG:32633', EXPRESSION:
> '"<qgis._core.QgsProcessingModelChildParameterSource object at
> 0x7f0f3e23be58>@1" = 12', EXTENT:
> '/home/jgr/Documentos/Classification/classification.tif', LAYERS: '',
> OUTPUT:
>
> '/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/b2be67056f714fcca6a0317233b4b134/OUTPUT.tif'
> }
> OK. Execution took 0.321 s (1 outputs).
> Prepare algorithm: gdal:polygonize_1
> Running Polygonize (raster to vector) [2/2]
> Input Parameters:
> { BAND: 1, EIGHT_CONNECTEDNESS: False, FIELD: 'DN', INPUT:
>
> '/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/b2be67056f714fcca6a0317233b4b134/OUTPUT.tif',
> OUTPUT:
>
> '/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ed2a4eb50e1d4a6ebe98392ea9f1c520/gdal_polygonize_1_reindeer
> polygons.shp' }
> GDAL command:
> gdal_polygonize.py
>
> /tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/b2be67056f714fcca6a0317233b4b134/OUTPUT.tif
>
> "\"/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ed2a4eb50e1d4a6ebe98392ea9f1c520/gdal_polygonize_1_reindeer
> polygons.shp\"" -b 1 -f "ESRI Shapefile" None DN
> GDAL command output:
> ERROR 1: Failed to create directory
>
> "/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ed2a4eb50e1d4a6ebe98392ea9f1c520/gdal_polygonize_1_reindeer
> polygons.shp" for shapefile datastore.
>
> Creating output
>
> "/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ed2a4eb50e1d4a6ebe98392ea9f1c520/gdal_polygonize_1_reindeer
> polygons.shp" of format ESRI Shapefile.
>
> Traceback (most recent call last):
>
> File "/usr/bin/gdal_polygonize.py", line 197, in <module>
>
> dst_layer = dst_ds.CreateLayer(dst_layername, geom_type=ogr.wkbPolygon,
> srs = srs )
>
> AttributeError: 'NoneType' object has no attribute 'CreateLayer'
>
> OK. Execution took 0.144 s (1 outputs).
> Model processed OK. Executed 2 algorithms total in 0.772 s.
> Execution completed in 0.79 seconds
> Results:
> {'gdal:polygonize_1:reindeer polygons':
> <QgsProcessingOutputLayerDefinition
>
> {'sink':/tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ed2a4eb50e1d4a6ebe98392ea9f1c520/gdal_polygonize_1_reindeer
> polygons.shp, 'createOptions': {'fileEncoding': 'System'}}>}
>
> Loading resulting layers
> The following layers were not correctly generated.
>
> /tmp/processing_7b5b06e1a8f14ee09ac38187a00ce932/ed2a4eb50e1d4a6ebe98392ea9f1c520/gdal_polygonize_1_reindeer
> polygons.shp
> You can check the 'Log Messages Panel' in QGIS main window to find more
> information about the execution of the algorithm.
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180613/315fd8cd/attachment-0001.html>


More information about the QGIS-Developer mailing list