Purpose
Returns the centroid (center point) of an object. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Centroid( obj_expr )
obj_expr is an object expression.
Return Value
Point object
Description
The Centroid() function returns a point object, which is located at the centroid of the specified obj_expr object. A region's centroid does not represent its center of mass. Instead, it represents the location used for automatic labeling, geocoding, and placement of thematic pie and bar charts. If you edit a map in reshape mode, you can reposition region centroids by dragging them.
If the obj_expr parameter represents a point object, the Centroid() function returns the position of the point. If the obj_expr parameter represents a line object, the Centroid() function returns the point midway between the ends of the line.
If the obj_expr parameter represents a polyline object, the Centroid() function returns a point located at the mid point of the middle segment of the polyline.
If the obj_expr parameter represents any other type of object, the Centroid() function returns a point located at the true centroid of the original object. For rectangle, arc, text, and ellipse objects, the centroid position is halfway between the upper and lower extents of the object, and halfway between the left and right extents. For region objects, however, the centroid position is always on the object in question, and therefore may not be located halfway between the object's extents.
Example
Dim pos As Object
Open Table "world"
Fetch First From world
pos = Centroid(world.obj)
See Also:
Alter Object statement, CentroidX() function, CentroidY() function