13

I have a problem in computing the centroids of certain polygons in QGIS (via the geometry tools): for certain polygons - with a strange and rather long shape - the centroids computed are off the polygon. Look, for instance, at the polygon marked in red, in the picture below:

enter image description here

Its centroid (pointed at by the blue arrow) is actually falling outside the polygon of interest. This occurs for a handful of (yet annoying) other polygons.

I am relatively new to QGIS, so I don't think whether this problem is due to the projection of the shapefile with the polygons (WGS 84). I tried anyway by re-projecting the map with WGS84/UTM Zone 31, which corresponds to Belgium (the country I'm looking at).

I have not found an answer to a similar questions in past discussions; apologies if I accidentally overlooked it.

16

I think the standard QGIS polygon centroid tools calculate the centre of mass in order to determine the polygon's centroid. So this could lie outside the polygon itself (nothing to do with projection).

If you want the calculate the centroid in terms of its dimensions, you could use the realcentroid plugin instead which you can download from:

Plugins > Manage and Install Plugins...

Example:

An irregular polygon with the red circle calculated from the Polygon centroid tool from QGIS (and SAGA); the green circle calculated from the realcentroid plugin:

Result


There is also an online script which produces the same result as the plugin which you can download from:

Processing Toolbox > Scripts > Tools > Get scripts from on-line scripts collection

And find the Real centroid script.

  • 1
    Yep, QGIS uses center of mass also called the geometric barycenter as centroid. – Jakob Apr 10 '17 at 9:54
  • 6
    I don't like the name "Real centroid". Point on surface would be better because centroid just is by definition what it is en.wikipedia.org/wiki/Centroid. – user30184 Apr 10 '17 at 9:56
  • 1
    @user30184 - Indeed, the description in the plugin also reads that the functionality is similar to the ST_PointOnSurface PostGIS function. – Joseph Apr 10 '17 at 10:00
  • @Andrea - Most welcome, glad it helped :) – Joseph Apr 10 '17 at 10:14
  • 2
    There are many centroid defs, don't get hung up on the "real one". – mdsumner Apr 10 '17 at 11:01
9

Proessing QGIS Algorithms has "Point on Surface" too, under Vector geometry tools group. No need to use external plugins nor DBs

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.