[postgis-users] Center of Points
Gustavo Henrique Sberze Ribas
gribas at cpqd.com.br
Thu Mar 9 03:41:11 PST 2006
Hello,
> Select
> AsText(Centroid(geomcollfromtext('GEOMETRYCOLLECTION(POINT(..
> ..),POINT( .. ..),..)',4326)))
>
> and i got back POINT(nan nan);
>
> How can I get the center of many points?
This seems to be the correct approach, however I'd transform the
coordinates to UTM before attempting any cartesian calculation.
What version of postgis are you using? The following example works
fine for me. In the picture, the polygon depicts the convex hull
of the geometry collection and the black dot is the centroid.
select asText(centroid(geomCollFromText('
GEOMETRYCOLLECTION (
POINT(-47.2412222222222 -22.7405833333333)
POINT(-47.3199166666667 -22.7333333333333)
POINT(-47.3545555555556 -22.7443055555556)
POINT(-47.3008346557617 -22.7133331298828)
POINT(-47.3302764892578 -22.731388092041)
POINT(-47.3406111111111 -22.76525)
POINT(-47.29525 -22.7161388888889)
POINT(-47.3481666666667 -22.7247222222222)
POINT(-47.3160277777778 -22.7383888888889)
POINT(-47.3275 -22.7459722222222)
POINT(-47.34025 -22.7523333333333)
POINT(-47.3368988037109 -22.7385997772217)
POINT(-47.3527793884277 -22.7352771759033)
POINT(-47.3476388888889 -22.7324444444444)
POINT(-47.3481666666667 -22.7247222222222)
POINT(-47.2624722222222 -22.7496944444444)
POINT(-47.34025 -22.7523333333333)
POINT(-47.3160277777778 -22.7383888888889)
POINT(-47.3406111111111 -22.76525)
POINT(-47.3275 -22.7459722222222)
POINT(-47.3001944444444 -22.7144444444444)
POINT(-47.3520555555556 -22.7320277777778)
POINT(-47.2952222222222 -22.7311111111111)
POINT(-47.3071944444444 -22.7513888888889)
POINT(-47.2978611111111 -22.7079722222222)
POINT(-47.3025833333333 -22.7260555555556)
POINT(-47.3317777777778 -22.7485)
POINT(-47.2861111111111 -22.7694444444444)
POINT(-47.2861111111111 -22.7722222222222)
POINT(-47.2944444444444 -22.775)
POINT(-47.2861111111111 -22.7805555555556)
POINT(-47.5083333333333 -22.5055555555556))',4326)))
--
Gustavo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: centroid.gif
Type: image/gif
Size: 4080 bytes
Desc: centroid.gif
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060309/8546aab8/attachment.gif>
More information about the postgis-users
mailing list