[postgis-users] noob question

Brent Wood pcreso at pcreso.com
Wed Jul 4 11:16:17 PDT 2007

--- Steve Lefevre <lawpoop at gmail.com> wrote:

> Hello all -
> I'm working on a database with GIS data. In my table,  I have columns for
> latitude, longitude, and coordinates, which is the Postgis geometry data
> type. What I would like to do is find the midpoint or 'average' for any
> group of points.
> I have the latitude and longitude, and then I use this syntax to create the
> coordinates column value:

Hi Steve,

Hope this helps...

If I understand you correctly, this may be easier outside of PostGIS
geometries, try:

select geometryfromtext(('POINT( avg(longitude) avge(latitude) ',4326)
group by ....

Always assuming the avg() is a appropriate value to use for your purposes.

If you didn't have the lat/long values outside a POINT geometry column, the
same result would be achieved by:
select geometryfromtext(('POINT( avg(X(coords)) avg(Y(coords)) ',4326)
group by...


   Brent Wood

> UPDATE table SET coords =  geometryfromtext('POINT( longitude latitude )',
> 4326)
> ( 4326 is the projection value that I understand is useful in the United
> States.
> So now that I have a bunch of lats, longs, and coordinates, I need to find
> the center point for any group of them. I can do a select query to get the
> specific records I'm looking for, and then I can have the list of lat&long
> points, or the coordinate geometry. How then do I take those rows and create
> an SQL st
> UPDATE table SET coords = geometryfromtext(' MULTIPOINT( $lat1 $long1,
> $lat2 $long2, $lat3 $long3)', 4326)
> Can I use the 'coords' geometry object instead?
> -- 
> "Computers are useless. They can only give you answers"
> -- Pablo Picasso
> > _______________________________________________
> 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