3

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.

grid

3

2 Answers 2

5

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

enter image description here

4

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))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.