Bug report #17287

OGR processing of scratch layers doesn't work

Added by Tobias Wendorff over 6 years ago. Updated over 6 years ago.

Status:Closed
Priority:Normal
Assignee:Giovanni Manghi
Category:Processing/OGR
Affected QGIS version:2.18.13 Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:25185

Description

I've created a point on a scratch layer (EPSG:4326) and want to create an ogr2ogr buffer using "processing".
The result is an error, as you can see on the animated gif attached.

qgis3_bug_gdal_scratch.gif (236 KB) Tobias Wendorff, 2017-10-16 01:29 AM

Associated revisions

Revision 4a51c408
Added by Alexander Bruy over 6 years ago

[processing] correctly handle layers without attributes in GDAL-based
geoprocessing algorithms (fix #17287)

Revision 034baf1b
Added by Nyall Dawson over 6 years ago

Merge pull request #5436 from alexbruy/processing-gdal-memory

[processing] correctly handle layers without attributes in GDAL-based geoprocessing algorithms (fix #17287)

History

#1 Updated by Tobias Wendorff over 6 years ago

Copy of the error message:

Algorithm 'Buffer vectors' starting...
Input parameters:
{ 'INPUT' : 'Point?crs=EPSG:4326&uid={fb3f5b3a-77ef-461f-876b-8e13f9e20cf4}', 'GEOMETRY' : 'geometry', 'DISTANCE' : 10, 'FIELD' : '', 'DISSOLVE' : False, 'EXPLODE_COLLECTIONS' : False, 'OPTIONS' : '', 'OUTPUT' : 'C:/Users/test/AppData/Local/Temp/processing_b3eeb99e5a0c4e5f990f7c7b7d49a8d6/beb3eb9ca76546efa9be8f327ce40fa4/OUTPUT.shp' }

GDAL command:
ogr2ogr "C:/Users/test/AppData/Local/Temp/processing_b3eeb99e5a0c4e5f990f7c7b7d49a8d6/beb3eb9ca76546efa9be8f327ce40fa4/OUTPUT.shp" C:/Users/test/AppData/Local/Temp/processing_b3eeb99e5a0c4e5f990f7c7b7d49a8d6/0db7b207ed4a459799cd887f39ac6a98/INPUT.shp -dialect sqlite -sql "SELECT ST_Union(ST_Buffer(geometry, 10.0)) AS geometry, FROM 'INPUT'" -f "ESRI Shapefile" 
GDAL command output:
ERROR 1: In ExecuteSQL(): sqlite3_prepare_v2(SELECT ST_Union(ST_Buffer(geometry, 10.0)) AS geometry, FROM 'INPUT'): 
near "FROM": syntax error 
Execution completed in 0.64 seconds
Results:
{'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':C:/Users/test/AppData/Local/Temp/processing_b3eeb99e5a0c4e5f990f7c7b7d49a8d6/beb3eb9ca76546efa9be8f327ce40fa4/OUTPUT.shp, 'createOptions': {'fileEncoding': 'System'}}>}

Loading resulting layers
Algorithm 'Buffer vectors' finished

Seems like the comma is wrong :)

#2 Updated by Tobias Wendorff over 6 years ago

Argh... of course the comma is wrong. It expects a field! But this isn't needed...

#3 Updated by Nyall Dawson over 6 years ago

  • Status changed from Open to Feedback

Does it work correctly if you add a field to the memory layer?

I suspect this issue isn't related to the use of a memory layer, but rather that the algorithms don't work correctly with layers with no fields. In which case it's likely also an issue in 2.x

#4 Updated by Tobias Wendorff over 6 years ago

Nyall Dawson wrote:

Does it work correctly if you add a field to the memory layer?

Yes it does.

I suspect this issue isn't related to the use of a memory layer, but rather that the algorithms don't work correctly with layers with no fields. In which case it's likely also an issue in 2.x

It didn't work in 2.x:

Algorithm Buffer vectors starting...

cannot concatenate 'str' and 'NoneType' objects See log for more details

But it should work in ogr2ogr! Without the comma, I'm getting the correct result.

ogr2ogr "C:/Users/test/AppData/Local/Temp/processing_b3eeb99e5a0c4e5f990f7c7b7d49a8d6/beb3eb9ca76546efa9be8f327ce40fa4/OUTPUT.shp" C:/Users/test/AppData/Local/Temp/processing_b3eeb99e5a0c4e5f990f7c7b7d49a8d6/0db7b207ed4a459799cd887f39ac6a98/INPUT.shp -dialect sqlite -sql "SELECT ST_Union(ST_Buffer(geometry, 10.0)) AS geometry, FROM 'INPUT'" -f "ESRI Shapefile"

Could you perhaps add the comma only, if fields.length > 0 ?

#5 Updated by Nyall Dawson over 6 years ago

  • Affected QGIS version changed from master to 2.18.13

#6 Updated by Giovanni Manghi over 6 years ago

isn't this duplicate of #16524 ?

#7 Updated by Tobias Wendorff over 6 years ago

Giovanni Manghi wrote:

isn't this duplicate of #16524 ?

No, I'm using the core function and my processing doesn't start at all, since the OGR commandline breaks.

#8 Updated by Giovanni Manghi over 6 years ago

  • Status changed from Feedback to Open
  • Assignee changed from Victor Olaya to Giovanni Manghi

#9 Updated by Giovanni Manghi over 6 years ago

  • Subject changed from QGIS3: OGR processing of scratch layers doesn't work to OGR processing of scratch layers doesn't work

#10 Updated by Giovanni Manghi over 6 years ago

I have a fix in the works for master/qgis3 (for the buffer tool at least), for qgis2 I really think that the issue is the same of #16524 : in Processing scratch layers (with or without fields) are not supported.

#11 Updated by Giovanni Manghi over 6 years ago

A better and more complete fix for master https://github.com/qgis/QGIS/pull/5436

#12 Updated by Alexander Bruy over 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF