https://issues.qgis.org/https://issues.qgis.org/favicon.ico2018-10-05T12:52:08ZQGIS Issue TrackingQGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=939272018-10-05T12:52:08ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Assignee</strong> set to <i>Giovanni Manghi</i></li></ul><p>Assigning to myself unless you have a patch in the works(?). This probably affects also the buffer tool (that has a dissolve option).</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=939312018-10-05T14:15:36ZAndrea Giudiceandreaandreaerdna@libero.it
<ul></ul><p>Giovanni Manghi wrote:</p>
<blockquote>
<p>Assigning to myself unless you have a patch in the works(?).</p>
</blockquote>
<p>I'm not working on a patch. Thanks for your commitment.</p>
<blockquote>
<p>This probably affects also the buffer tool (that has a dissolve option).</p>
</blockquote>
<p>ST_Union() is used in Buffer.py and in OneSideBuffer.py but they are not affected because the output layer for these algs is of polygon geometry type and the issue doesn't occur for line/multiline or polygon/multipolygon shapefile output layers.</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=949162018-10-28T12:56:22ZAndrea Giudiceandreaandreaerdna@libero.it
<ul><li><strong>Affected QGIS version</strong> changed from <i>3.3(master)</i> to <i>3.4.0</i></li></ul><p>Confirmed on 3.4.0</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=986992019-01-22T09:58:41ZAlexander Bruy
<ul></ul><p>Can you share small dataset allowing to reproduce issue?</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=987512019-01-22T21:18:17ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=987632019-01-22T22:03:58ZAndrea Giudiceandreaandreaerdna@libero.it
<ul><li><strong>File</strong> <a href="/attachments/download/14139/testpoints.zip">testpoints.zip</a> added</li></ul><p>Alexander Bruy wrote:</p>
<blockquote>
<p>Can you share small dataset allowing to reproduce issue?</p>
</blockquote>
<p>The GDAL/OGR Dissolve algorithm (Dissolve field set to TestField - output set to "Save to temporary file" or to a shapefile) fails with the attached testpoints.zip zipped Shapefile that contains the following 6 points:</p>
<pre>
id TestField
0 1 AAA
1 2 BBB
2 3 AAA
3 4 AAA
4 5 CCC
5 6 BBB
</pre><br />The algorithm log window shows:
<pre>
Processing algorithm…
Algorithm 'Dissolve' starting…
Input parameters:
{ 'COMPUTE_AREA' : False, 'COMPUTE_STATISTICS' : False, 'COUNT_FEATURES' : False, 'EXPLODE_COLLECTIONS' : False, 'FIELD' : 'TestField', 'GEOMETRY' : 'geometry', 'INPUT' : 'C:\\testdissolvepoint\\testpoints.shp', 'KEEP_ATTRIBUTES' : False, 'OPTIONS' : '', 'OUTPUT' : 'C:/testdissolvepoint/testdissolvedpoints.shp', 'STATISTICS_ATTRIBUTE' : None }
GDAL command:
ogr2ogr C:/testdissolvepoint/testdissolvedpoints.shp C:\testdissolvepoint\testpoints.shp -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, TestField FROM 'testpoints' GROUP BY TestField" -f "ESRI Shapefile"
GDAL command output:
ERROR 1: Attempt to write non-multipoint (POINT) geometry to multipoint shapefile.
ERROR 1: Unable to write feature 2 from layer SELECT.
ERROR 1: Terminating translation prematurely after failed
translation from sql statement.
Execution completed in 1.96 seconds
Results:
{'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':C:/testdissolvepoint/testdissolvedpoints.shp, 'createOptions': {'fileEncoding': 'System'}}>}
Loading resulting layers
Algorithm 'Dissolve' finished
</pre>
<p>The resulting output Shapefile contains only the following 2 multipoint features</p>
<pre>
TestField
0 AAA
1 BBB
</pre>
<p>instead of 3 multipoint features:</p>
<pre>
TestField
0 AAA
1 BBB
2 CCC
</pre> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=987652019-01-22T22:16:05ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Open</i></li><li><strong>Affected QGIS version</strong> changed from <i>3.4.0</i> to <i>3.4.4</i></li></ul><p>Andrea Giudiceandrea wrote:</p>
<blockquote>
<p>Alexander Bruy wrote:</p>
<blockquote>
<p>Can you share small dataset allowing to reproduce issue?</p>
</blockquote>
<p>The GDAL/OGR Dissolve algorithm (Dissolve field set to TestField - output set to "Save to temporary file" or to a shapefile) fails with the attached testpoints.zip zipped Shapefile that contains the following 6 points:</p>
</blockquote>
<p>this tool is ogr2ogr based, specifically ogr2ogr is used to launch a spatial query, in this case:</p>
<p>SELECT ST_Union(geometry) AS geometry, TestField FROM 'testpoints' GROUP BY TestField</p>
<p>we must modify it and add a "-nlt MULTI*" parameter.</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=988152019-01-23T17:35:25ZAlexander Bruy
<ul></ul><p>Giovanni Manghi wrote:</p>
<blockquote>
<p>this tool is ogr2ogr based, specifically ogr2ogr is used to launch a spatial query, in this case:</p>
<p>SELECT ST_Union(geometry) AS geometry, TestField FROM 'testpoints' GROUP BY TestField</p>
<p>we must modify it and add a "-nlt MULTI*" parameter.</p>
</blockquote>
<p>I see, but works fine even without it with my test data and QGIS test data. That's why I asked for some dataset.<br />Also I'm not sure if always casting output to multigeometry is correct. As I understand, dissolve also can produce singleparts. Maybe better to implement some logic and produce multiparts only if input layer is multipart?</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=988272019-01-23T22:42:57ZAndrea Giudiceandreaandreaerdna@libero.it
<ul></ul><p>Alexander Bruy wrote:</p>
<blockquote>
<p>Also I'm not sure if always casting output to multigeometry is correct. As I understand, dissolve also can produce singleparts. Maybe better to implement some logic and produce multiparts only if input layer is multipart?</p>
</blockquote>
<p>Note that the provided "testpoints" dataset is a simple point shapefile, not a multipoint.</p>
<p>If trivially dissolved by the "id" field, the output shapefile could have a simple point geometry type.</p>
<p>But if dissolved by the "TestField" field, the output will contain 2 multipart point features and 1 singlepart point feature: in this case, the only way to store the output in a shapefile, is to force ogr2ogr to always create multipart point features and use a multipoint shapefile (because point and multipoint features cannot be stored together in a point shapefile nor in a multipoint shapefile).</p>
<p>As previously said, the issue doesn't occur for mixed singlepart/multipart features in a PolyLine or in a Polygon shapefile.</p>
<p>So I think that, only for point/multipoint input layer, the GDAL/OGR Dissolve algorithm should be fixed in order to always generate multipoint features as output, at least when the output is set to "Save to temporary file" (the default option) or is a shapefile.</p>
<p>We can use</p>
<p>SELECT ST_Multi(ST_Union({})) instead of SELECT ST_Union({}) in the sql string passed to ogr2ogr</p>
<p>as proposed by me,</p>
<p>or we can add "-nlt MULTIPOINT" to the ogr2ogr command</p>
<p>as proposed by Giovanni.</p>
<p>EDIT: also "-nlt PROMOTE_TO_MULTI"</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=988292019-01-24T01:26:38ZNyall Dawson
<ul></ul><p>I think always upgrading to multipart is the correct choice here -- that's what the native QGIS dissolve algorithm does too.</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=988962019-01-24T17:35:19ZAlexander Bruy
<ul><li><strong>Pull Request or Patch supplied</strong> changed from <i>No</i> to <i>Yes</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>In Progress</i></li><li><strong>Assignee</strong> changed from <i>Giovanni Manghi</i> to <i>Alexander Bruy</i></li></ul><p>PR <a class="external" href="https://github.com/qgis/QGIS/pull/8972">https://github.com/qgis/QGIS/pull/8972</a></p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=989162019-01-24T22:56:45ZAlexander Bruy
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/32f6034be708b305ed4e19b4f6ade1a8b409993b" title="[processing][needs-docs] force multipart output from GDAL-based dissolve algorithm (fix #20025)">qgis|32f6034be708b305ed4e19b4f6ade1a8b409993b</a>.</p> QGIS Application - Bug report #20025: GDAL/OGR Dissolve algorithm not properly working with point/multipoint layershttps://issues.qgis.org/issues/20025?journal_id=989222019-01-25T06:08:18ZAlexander Bruy
<ul><li><strong>Resolution</strong> set to <i>fixed/implemented</i></li></ul>