Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

ST_Centroid

Focus mode
ST_Centroid - Amazon Redshift

ST_Centroid returns a point that represents a centroid of a geometry as follows:

  • For POINT geometries, it returns the point whose coordinates are the average of the coordinates of the points in the geometry.

  • For LINESTRING geometries, it returns the point whose coordinates are the weighted average of the midpoints of the segments of the geometry, where the weights are the lengths of the segments of the geometry.

  • For POLYGON geometries, it returns the point whose coordinates are the weighted average of the centroids of a triangulation of the areal geometry where the weights are the areas of the triangles in the triangulation.

  • For geometry collections, it returns the weighted average of the centroids of the geometries of maximum topological dimension in the geometry collection.

Syntax

ST_Centroid(geom)

Arguments

geom

A value of data type GEOMETRY or an expression that evaluates to a GEOMETRY type.

Return type

GEOMETRY

If geom is null, then null is returned.

If geom is empty, then null is returned.

Examples

The following SQL returns central point of an input linestring.

SELECT ST_AsEWKT(ST_Centroid(ST_GeomFromText('LINESTRING(110 40, 2 3, -10 80, -7 9, -22 -33)', 4326)))
st_asewkt ---------------------------------------------------- SRID=4326;POINT(15.6965103455214 27.0206782881905)

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.