I have an SDE.ST_GEOMETRY polygon FC in an Oracle 18c/10.7.1 geodatabase.

I can calculate the X and Y of the polygon centroids using the SDE.ST_GEOMETRY ST_Centroid function:

sde.st_x(sde.st_centroid(shape)) as x,
sde.st_y(sde.st_centroid(shape)) as y    

ST_Centroid takes a polygon, multipolygon, or multilinestring and returns the point that is in the center of the geometry's envelope. That means that the centroid point is halfway between the geometry's minimum and maximum x and y extents.

Unfortunately, the polygons are irregularly shaped, and therefore the centroids do not fall within the polygon boundaries:

enter image description here

Is there a way to calculate polygon center-points that fall within the polygons?

  • side note: is that definition of the centroid from the function documentation? Because "That means that the centroid point is halfway between the geometry's minimum and maximum x and y extents." is not the accepted definition of a centroid... Wow, yes it is in the docs... Hmmm.
    – Spacedman
    Commented Apr 1, 2020 at 17:41
  • 1
    docs.oracle.com/database/121/SPATL/… Commented Apr 1, 2020 at 17:53
  • I can think of a complicated way to get what you want...rasterize the polygon, skeletonize it, find the longest path from all the skeleton endpoints to all other skeleton endpoints, then take the middle pixel in that path as the "centroid." This would effectively be a kind of "within bounds" average position.
    – Jon
    Commented Apr 1, 2020 at 18:11
  • 1
    You want the SDE.ST_PointOnSurface function, not SDE.ST_Centroid (remember, there was a design committee for the Simple Features standard).
    – Vince
    Commented Apr 1, 2020 at 18:15
  • The SF standard seems to have a note No specific algorithm is specified for the Centroid function; answers may vary with implementation.. I have thought that it should be at the centre of mass as it is in PostGIS postgis.net/docs/ST_Centroid.html.
    – user30184
    Commented Apr 2, 2020 at 8:27

1 Answer 1


As @Vince suggested, this can be done with the SDE.ST_PointOnSurface function:

sde.st_x(sde.st_pointonsurface(.shape)) as x,
sde.st_y(sde.st_pointonsurface(.shape)) as y     

ST_PointOnSurface takes an ST_Polygon or ST_MultiPolygon and returns an ST_Point guaranteed to lie on its surface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.