[postgis-users] Centroid Within Multi Part Polygon

Simon Greener simon at spatialdbadvisor.com
Mon Jun 18 15:07:56 PDT 2007


Someone asked recently about a centroid function which guaranteed that
the created centroid:

1. Fell within a polygon (not outside it as is the case with
implementations that average the X and Y coords of an area);
2. If the polygon is multi-part, put the centroid in the largest part.

I have just such a function but it is currently Oracle PL/SQL based. It
does both of the above + also have an overloaded version which will
return a multi-point object wherein each point is the centroid of each
disperate part in a multi-part polygon. The functions have been heavily
tested with many datasets and are pretty well guaranteed to work. I also
have a Java version.

I do not know PostgreSQL's implementation of PL/SQL but I suspect I
could convert the code pretty easily.  I do not have the time at the
moment to convert them but if anyone wants to download them from my
website (see below) and convert them please feel free. All I ask if for
a copy of the PostgreSQL implementation for hosting back on my website.

regards
Simon
--
SpatialDB Advice and Solutions Architecture,
Oracle Spatial, ArcSDE, Manifold GIS, Radius Topology and Studio
Specialist.
39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
Website: www.spatialdbadvisor.com
   Email: simon at spatialdbadvisor.com
   Voice: +61 362 396397
Mobile: +61 418 396391
Skype: sggreener
Longitude: 147.20515
Latitude: -43.01530
NAC:W80CK 7SWP3



More information about the postgis-users mailing list