Knowledge Base

KB10355 - Calculate centroid point of an irregular shaped polygon.

The DK and Editor support two possibilities:

  1. Calculate the true centriod position, regardless whether or not it lies within or outside the polygon area. Use - TGIS_Shape.Centroid
  2. Calculate the point within the polygon area closest to the true centroid position, to guarantee the calculated point is within the polygon boundary. Use - TGIS_Shape.PointOnShape

It is possible to use a given point to reposition (move) an irregularly shaped polygon, such that the point becomes the centroid of the polygon in its new location. To do this, use:

shp.SetPosition( new_centroid_pos ) ;
Created: November 21, 2003, Modified: August 03, 2015