The answer is no.

For a convex polygon or one with holes, the centroid may well be outside the 
polygon.

What I typically do for this situation is create a point column in the polygon 
table & run an update to populate it with the centroid. Then run a second 
update calling 

ST_PointOnSurface(geom) where not contains(poly,point)

If I was being picky, I'd probaby run an intermediate update to try the 
centroid of the convex hull of the geometry first, then ST_PointOnSurface to 
clean up the remainder. Just to get centroids nearer the center than 
ST_PointOnSurface() may return.


 
HTH,

  Brent Wood



--- On Sat, 5/2/09, Paragon Corporation <[email protected]> wrote:

> From: Paragon Corporation <[email protected]>
> Subject: RE: [postgis-users] st_centroid Points not on Polygon
> To: "'PostGIS Users Discussion'" <[email protected]>
> Date: Saturday, May 2, 2009, 10:20 AM
> 
> Message
>  
>  
>  
> Stan,
> I think the answer is no. 
> For example if you have a 
> polygon with holes, the centroid may very well lie in the 
> hole.
>  
> Leo
> 
> 
> 
> From: 
> [email protected] 
> [mailto:[email protected]]
> On Behalf Of 
> Sufficool, Stanley
> Sent: Friday, May 01, 2009 4:53 
> PM
> To: PostGIS Users Discussion
> Subject: [postgis-users] 
> st_centroid Points not on Polygon
> 
> 
> 
> I'm sure I ran 
> across this in the forums a year ago,
> but:
>  
> Is the st_centroid 
> function guaranteed to return a point that lies on the
> polygon? I have instances 
> when my display doe not place it on the polygon when using 
> st_centroid(st_intersection(the_geom, <WKT
> BBOX>));
>  
> Thanks in 
> advance. 
> 
> -----Inline Attachment Follows-----
> 
> _______________________________________________
> postgis-users mailing list
> [email protected]
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to