[postgis-users] Center of Points Collection

pcreso at pcreso.com pcreso at pcreso.com
Tue Sep 15 12:39:54 PDT 2009


Hi Chris,

Sorry, I didn't put that well, I meant the centroid of the extent (bbox) is defined by the outliers, not the centroid of the dataset, in my hierarchy of arbitrary representativeness :-) 

I ain't really a PL/R user, but I'd like to be one. Only 24 hrs in the day, & I don't know R well enough, I have several workmates who are more than competent with R, & I work with them for R expertise - much easier & there are already too many things I don't do well!.

Back on topic, I'd regard a centroid as the ultimate endpoint of a clustering analysis, & while in PostGIS it does seem to be a simple averaging approach, there are many more ways to do this. See 

http://en.wikipedia.org/wiki/Cluster_analysis

for some examples of how you might otherwise determine a centroid. Or look up weighted averaging...


Cheers,

  Brent


--- On Wed, 9/16/09, Chris Hermansen <chris.hermansen at timberline.ca> wrote:

> From: Chris Hermansen <chris.hermansen at timberline.ca>
> Subject: Re: [postgis-users] Center of Points Collection
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Date: Wednesday, September 16, 2009, 7:15 AM
> Cool, a PL/R user!
> 
> Brent, I'm curious about why you make a distinction between
> the centroid and the average, because as far as I can tell
> they are the same thing.
> 
> pcreso at pcreso.com
> wrote:
> > Hi guys,
> > 
> > A bit more difficult, & way out in left field, but
> if you use PL/R to create a median function for Postgres,
> you could build your point from the median(X) & (Y)
> values instead of the average.
> > 
> > Where this would actually lie obviously depends on the
> distribution of the points. The centroid is most affected by
> (actually defined by) outlying points, the avg somewhat less
> & the median less still.
> > 
> > Of course once you have PL/R to play with, you have
> much more flexibility to look at returning statistics from
> datasets than just the median.
> > 
> > Cheers,
> > 
> >   Brent Wood
> > 
> > 
> > 
> > 
> > --- On Tue, 9/15/09, Kevin Neufeld <kneufeld at refractions.net>
> wrote:
> > 
> >   
> >> From: Kevin Neufeld <kneufeld at refractions.net>
> >> Subject: Re: [postgis-users] Center of Points
> Collection
> >> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> >> Date: Tuesday, September 15, 2009, 8:51 AM
> >> Paul Ramsey wrote:
> >>     
> >>> Faster than creating a multipoint is to
> recognize that
> >>>       
> >> ST_Centroid()
> >>     
> >>> is just going to return the center of the bbox
> of the
> >>>       
> >> collection
> >>     
> >>> anyways...
> >>>       
> >> Unfortunately, Paul, ST_Centroid returns the
> center of
> >> mass, not the center of the bbox.
> >> 
> >> SELECT astext(st_centroid(st_collect(column1))),
> >> FROM (values ('POINT(0 0)'),
> >>         
>    ('POINT(0 1)'),
> >>         
>    ('POINT(0 2)'),
> >>         
>    ('POINT(1 0)')) as foo;
> >>       astext
> >> ------------------
> >>  POINT(0.25 0.75)
> >> (1 row)
> >> 
> >> 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.
> >> 
> >> SELECT astext(st_makepoint(avg(st_x(column1)),
> >> avg(st_y(column1))))
> >> FROM (values ('POINT(0 0)'),
> >>         
>    ('POINT(0 1)'),
> >>         
>    ('POINT(0 2)'),
> >>         
>    ('POINT(1 0)')) as foo;
> >>       astext
> >> ------------------
> >>  POINT(0.25 0.75)
> >> (1 row)
> >> 
> >> If Dustin is after the center of the collection,
> then
> >> something along your first suggestion might be
> more
> >> appropriate.
> >> (taking the center of the extents)
> >> 
> >> Cheers,
> >> Kevin
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >> 
> >>     
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >   
> 
> 
> -- Regards,  (please note new mobile number below)
> 
> Chris Hermansen     
>    mailto:chris.hermansen at timberline.ca
> tel+1.604.714.2878 · fax+1.604.733.0631 ·
> mob+1.778.840.4625
> Timberline Natural Resource Group · http://www.timberline.ca
> 401 · 958 West 8th Avenue  · Vancouver BC · Canada
> · V5Z 1E5
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 



More information about the postgis-users mailing list