This is why I said depending on what you want.  <br><br>The average provides a weighted result, where a wild point will merely tug like a point on a bezier frame.  A statistical result.   Putting a bounding box around the whole thing and computing the center of that, provides an unweighted geometric result.  Which may be desirable.  Without providing some means, on a set of points that we have no description of, of ordering a shape, save order of occurence, the means of computing a centroid is indeterminate.<br>
<br>Interestingly enough, if the points are evenly spaced in circle with ordinate points, all three will get the same result.  (Completely manufactured, I know)  But I doubt that the question would have been raised if that were the case.<br>
<br>The question is what is the application.<br><br>Dustin?<br><br>My question, purely out of interest, is which would be faster?  My guess is the bounding box, with the median coming close on its heels.<br><br>Also, am I correct in assuming that a centroid strives to be the point at which, were a line drawn through it would split the area of the shape evenly?  If so, is this always possible, and if not, can exceptions be easily identified?<br>
<br><div class="gmail_quote">On Mon, Sep 14, 2009 at 4:51 PM, Kevin Neufeld <span dir="ltr"><<a href="mailto:kneufeld@refractions.net">kneufeld@refractions.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Paul Ramsey wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Faster than creating a multipoint is to recognize that ST_Centroid()<br>
is just going to return the center of the bbox of the collection<br></div>
anyways...<br>
</blockquote>
<br>
Unfortunately, Paul, ST_Centroid returns the center of mass, not the center of the bbox.<br>
<br>
SELECT astext(st_centroid(st_collect(column1))),<br>
FROM (values ('POINT(0 0)'),<br>
             ('POINT(0 1)'),<br>
             ('POINT(0 2)'),<br>
             ('POINT(1 0)')) as foo;<br>
      astext<br>
------------------<br>
 POINT(0.25 0.75)<br>
(1 row)<br>
<br>
Your second post, taking the avg of the x,y does seem to be the nice approach, and produces the same results as ST_Centroid - the center of mass.<br>
<br>
SELECT astext(st_makepoint(avg(st_x(column1)), avg(st_y(column1))))<br>
FROM (values ('POINT(0 0)'),<br>
             ('POINT(0 1)'),<br>
             ('POINT(0 2)'),<br>
             ('POINT(1 0)')) as foo;<br>
      astext<br>
------------------<br>
 POINT(0.25 0.75)<br>
(1 row)<br>
<br>
If Dustin is after the center of the collection, then something along your first suggestion might be more appropriate.<br>
(taking the center of the extents)<br>
<br>
Cheers,<br><font color="#888888">
Kevin</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Cheers!<br>Rick<br><br>