[postgis-users] Center of Points

Gregory S. Williamson gsw at globexplorer.com
Thu Mar 9 02:36:46 PST 2006

I think creating a linestring from many points would be problematic as it would cross over itself and do odd things.

Perhaps (untested):

a) load the point data as points (so take the x/y and make them into points with a common SRID (4326)
b) create a spatial index on the geometry column
c) obtain the bounding box of that column
d) get the centroid of the bounding box

Obviously, this can be inaccurate depending on the distribution of the data; 1 point off in La-La land will skew the bounding box horribly ... but if you were able to determine the points that define the perimiter of the points when visualized a polygon, they would produce a polygon that would also have a similar distortion. 


Greg Williamson
GlobeXplorer LLC

-----Original Message-----
From:	postgis-users-bounces at postgis.refractions.net on behalf of Jens Werdin
Sent:	Thu 3/9/2006 2:14 AM
To:	PostGIS Users Discussion
Subject:	[postgis-users] Center of Points
Hello everybody,

I have a problem finding the center of many points.
What i tries was: 
writing a script which gets the coordinates of the points i wanted:

select x(), y() from adresses where... order by x()

then I made a linestring out of the points and got the center:

Select AsText(Centroid(linestringfromtext('LINESTRING(.. .., .. ..,)',4326)))

but I think it is not correct enough. then i tried

AsText(Centroid(geomcollfromtext('GEOMETRYCOLLECTION(POINT(.. ..),POINT( .. ..),..)',4326)))

and i got back POINT(nan nan);

How can I get the center of many points?

Greetings Jens

postgis-users mailing list
postgis-users at postgis.refractions.net


More information about the postgis-users mailing list