I would like to determine the center of this layer, when I look for the centroid I get the centroid of each separate shape but I want the centroid of the total layer.
-
1Are you asking how to get the centroid of the bounding box?– ErikMay 4 at 12:11
-
2You can dissolve features before processing: docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/…– Comrade CheMay 4 at 12:12
-
@Erik yes, thank you for rephrasing!– N_LLCMay 4 at 12:20
2 Answers
You can achieve this using a virtual layer.
Go to the menu Layer > Add Layer > Add/Edit Virtual Layer...
, enter the following query and adjust for your layer name. You can then export the layer to persist its content.
To use the layer extent:
select st_centroid(extent(geometry)) from myLayer
To use the union of the polygons:
select st_centroid(ST_Union(geometry)) from myLayer
Use Menu Processing > Toolbox > Geometry by expression with this expression:
- for centroid of layer extent:
centroid (layer_property (@layer, 'extent'))
- for collected polygons:
centroid (collect ($geometry))