4

There is an option in the field calculator for centroids under geometry which when you double click gives you "centroid( ". What information is required here in order to use this function?

7

The centroid function returns an Point geometry object that represents the centroid of the input geometry.

You'd have to give the centroid function a geometry to chew on (most likely your feature's geometry, from $geometry), then parse that geometry out however you'd like.

One example would be getting the centroid as WKT:

 geomToWKT( centroid(  $geometry ) )

You could then stick that in a text field, or parse it further to get the X or Y.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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