[Qgis-developer] OGR Buffer fails in Processing

Paolo Cavallini cavallini at faunalia.it
Thu Mar 2 23:15:02 PST 2017


Il 3 marzo 2017 08:08:28 CET, Even Rouault <even.rouault at spatialys.com> ha scritto:
>On jeudi 2 mars 2017 23:34:17 CET Paolo Cavallini wrote:
>> Hi all,
>> a simple buffer fails if applied to a PostGIS layer:
>> ===
>> Algorithm Buffer vectors starting...
>> GDAL command:
>> ogr2ogr
>>
>"/tmp/processingf5bab9b07d834e229b9dd70899b8face/971076e5d374495280a95f7adf2
>> ec92a/OUTPUTLAYER.shp" "PG:dbname='corso' host=localhost port=5432
>> user='utente'
>> password='utente' sslmode=disable" public.fiumi -dialect sqlite -sql
>> "SELECT ST_Buffer( geometry , 100 ),* FROM 'public.fiumi' "
>> GDAL command output:
>> Warning 1: layer names ignored in combination with -sql.
>> ERROR 1: In ExecuteSQL(): sqlite3_prepare(SELECT ST_Buffer( geometry
>,
>> 100 ),* FROM 'public.fiumi' ):
>> no such column: geometry
>
>--> Just guessing blindly. I guess that the "'geometry" column name in
>ST_Buffer(geometry, 
>X) must be hardcoded in processing. This is the name of the geometry
>column used by 
>default for OGR sources that have no explicit geometry column (like
>shapefiles). But when 
>the source is a database, "geometry" must be replaced by the actual
>geometry column name 
>from the database. Typically the one you get with
>OGR_L_GetGeometryColumn().
>
>Pseudo code :
>
>src_geometry_column =  OGR_L_GetGeometryColumn(layer)
>if src_geometry_column is null or empty :
>     sqlite_geometry_column = 'geometry'
>else
>     sqlite_geometry_column = src_geometry_column
>
>Note: in the above case, the processing is a bit suboptimal as the
>source is PostGIS. Removing 
>-dialect sqlite would speed up things and allow the buffering to be
>done by PostGIS itself.
>
>> Converting outputs
>> Caricamento layer
>> 
>> The following layers were not correctly generated.
>> Buffer
>> You can check the log messages to find more information about the
>> execution of the algorithm
>> ===
>> Whereas it runs fine when applied to a shapefile.
>> All the best.
>
>
>-- 
>Spatialys - Geospatial professional services
>http://www.spatialys.com

Thanks a lot Even, very useful.
Cheers.
-- 
Sent from mobile. Sorry for being short
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170303/3729065a/attachment.html>


More information about the Qgis-developer mailing list