Skip to content

Conversation

@dbaston
Copy link
Member

@dbaston dbaston commented Nov 3, 2025

Adds gdal vector collect, an opposite operation to explode-collections. The --group-by option is used to control which features get combined.

Also adds gdal vector dissolve, which performs UnaryUnion on individual features. I think the name "Union" can be confusing (easily mistaken for https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/union.htm)

On the other hand, while "dissolve" captures the behavior for polygon and maybe point inputs, I don't think it's a good description of how lines are handled. (They're noded, but not combined.) I don't know if "dissolve" should apply GEOSLineMerge (https://postgis.net/docs/ST_LineMerge.html) to the outputs of UnaryUnion (thus "dissolving" the linestrings), or if I should just rename the operation to gdal vector unary-union or gdal vector union.

@dbaston dbaston added this to the 3.13.0 milestone Nov 3, 2025
@dbaston dbaston added the gdal_cli Anything related to the new 3.11 "gdal" CLI frontend label Nov 3, 2025
@coveralls
Copy link
Collaborator

coveralls commented Nov 3, 2025

Coverage Status

coverage: 71.359% (-0.001%) from 71.36%
when pulling 2b5fe2e on dbaston:collect-dissolve
into ea75dfb on OSGeo:master.

(
"programs/gdal_vector_concat",
"gdal-vector_concat",
"gdal-vector-concat",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just cherry-picked that fix in master

@rouault
Copy link
Member

rouault commented Nov 6, 2025

I don't know if "dissolve" should apply GEOSLineMerge (https://postgis.net/docs/ST_LineMerge.html) to the outputs of UnaryUnion (thus "dissolving" the linestrings)

That would probably be reasonable. Looking at QGIS dissolve algorithms in https://github.com/qgis/QGIS/blob/0ceeea4a5de28b3644392b7f0b10be220419ee5f/src/analysis/processing/qgsalgorithmdissolve.cpp#L281 , it calls QgsGeometry::mergeLines(), which I assume must do something similar to GEOSLineMerge, if the output of the unary union is linear

@dbaston
Copy link
Member Author

dbaston commented Nov 6, 2025

I don't especially like GEOS' approach of silently dropping non-linear geometries, so either GDAL will need to do some careful filtering of what it provides to GEOSLineMerge, or I'll need to expose a new LineMerge in GEOS that doesn't have that behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gdal_cli Anything related to the new 3.11 "gdal" CLI frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants