Closed
Description
https://docs.qgis.org/3.40/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html#centroids
It would be useful to have an option in the processing tool that takes an existing vector layer and generates a new layer where each feature is replaced by the centroid of its geometry. This can be helpful in cases where one wants to visualize or label central points of polygons.
The output should:
- Retain original feature attributes.
- Replace the geometry with a single point (centroid).
- Work for any polygon or multipolygon input.
A basic implementation could be done using ogr2ogr
:
[
'-f', 'GeoJSON',
'-dialect', 'sqlite',
'-sql', 'SELECT ST_Centroid(geometry) AS geometry, * FROM input'
]
The implementation would be quite similar to #602, just that this doesn't require any additional input parameter other than the layer itself which makes it a bit simpler.