geo-registry

Centroid

One point per feature, at its geometric centre or, if asked, at a point guaranteed to lie inside it.

Pitfall. The centroid of a concave or multipart polygon can fall outside it; use inside for labels and joins back to the polygon.
Pitfall. Centroids of data in a geographic CRS are computed on degrees and are slightly off the true centre on the ground.
About this operation
Also called Feature To Point, centroids, point on surface, representative point, label point
Group vector/geometry
Checks geometry.valid
Pitfalls 2 listed above
Columbus tool Not stated
Notes Not stated
Status active
Broader Not stated
Narrower Not stated
Related

Parameters

Name Type Required Default Values Note
inside boolean no no Not stated Use a point guaranteed to lie inside each polygon (point on surface) instead of the centroid.

Inputs and outputs

Direction Name Type Geometry Note
Input layer vector Not stated Not stated
Output output vector point Not stated

In each engine

Engine Tool Parameters Differences
apache-sedona sedona.sql.ST_Centroid
  • inside always no. Use ST_PointOnSurface for a point inside the polygon.
  • layer → geometry
  • A Spark SQL function: arguments are columns or column names, run over a Spark DataFrame.
apache-sedona sedona.sql.ST_PointOnSurface
  • inside always yes. Use ST_Centroid for the geometric centroid.
  • layer → geometry
  • A Spark SQL function: arguments are columns or column names, run over a Spark DataFrame.
geopandas geopandas.GeoSeries.centroid
  • inside always no. Use GeoSeries.representative_point() for a point inside the polygon.
  • A property of the GeoSeries, not a method; returns a GeoSeries without the other columns.
  • Warns when the CRS is geographic.
geopandas geopandas.GeoSeries.representative_point
  • inside always yes. Use GeoSeries.centroid for the geometric centroid.
  • Returns a GeoSeries without the other columns.
postgis st_centroid
  • inside always no. Use ST_PointOnSurface for a point inside the polygon.
  • layer → #1
  • On geography it computes a spheroidal centroid (use_spheroid).
postgis st_pointonsurface
  • inside always yes. Use ST_Centroid for the geometric centroid.
  • layer → #1
None noted
qgis native:centroids
  • inside always no. Use native:pointonsurface for a point inside the polygon.
  • layer → INPUT
  • output → OUTPUT
  • ALL_PARTS gives one point per part of multipart features.
qgis native:pointonsurface
  • inside always yes. Use native:centroids for the geometric centroid.
  • layer → INPUT
  • output → OUTPUT
  • ALL_PARTS gives one point per part of multipart features.
sf sf::st_centroid
  • inside always no. Use st_point_on_surface for a point inside the polygon.
  • layer → x
  • of_largest_polygon = TRUE gives the centroid of each feature's largest part.
sf sf::st_point_on_surface
  • inside always yes. Use st_centroid for the geometric centroid.
  • layer → x
None noted
shapely shapely.centroid
  • inside always no. Use shapely.point_on_surface for a point inside the polygon.
  • layer → geometry
None noted
shapely shapely.point_on_surface
  • inside always yes. Use shapely.centroid for the geometric centroid.
  • layer → geometry
None noted
terra terra::centroids
  • inside → inside
  • layer → x
None noted
turf-js turf.centroid
  • inside always no. Use turf.pointOnFeature for a point inside the polygon.
  • layer → geojson
  • The mean of all vertices, not the area-weighted centroid (turf.centerOfMass gives that).
  • Turf works on GeoJSON in longitude/latitude (WGS 84); data in another CRS must be reprojected first.
turf-js turf.pointOnFeature
  • inside always yes. Use turf.centroid for the geometric centroid.
  • layer → geojson
  • Turf works on GeoJSON in longitude/latitude (WGS 84); data in another CRS must be reprojected first.
whiteboxtools CentroidVector
  • inside always no
  • layer → input
  • output → output
None noted