[postgis-users] Computing a centroid on GEOGRAPHY objects

Stephen V. Mather svm at clevelandmetroparks.com
Thu Dec 6 13:34:40 PST 2012


ST_Centroid doesn't require a defined SRID, so in theory
ST_Centroid(geography_column::geometry) should work fine.

 

The biggest problem with such a cast is you could pretty easily come up with
strange centroid results because your are treating an angular coordinate
system as a planar one.  It may not be a problem, however, if your
geometries aren't spanning too large a geographic area.

 

Alternatively (and It would be a little messy), you could do a SELECT CASE
with constraints on longitudinal ranges to do individual casts as UTM (and
if you are working in polar regions, also have cases for latitudes for the
polar stereographics. ).  It would be a quasi-rigourous approach, but you
could transform them back after the centroid is calculated.

 

Best,
Steve

 

http://www.clemetparks.com/images/esig/cmp-ms-90x122.pngStephen Mather
Geographic Information Systems (GIS) Manager
(216) 635-3243

svm at clevelandmetroparks.com
 <http://www.clemetparks.com/> clevelandmetroparks.com

 

 

 

 

From: postgis-users-bounces at lists.osgeo.org
[mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Ed Linde
Sent: Thursday, December 06, 2012 4:21 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Computing a centroid on GEOGRAPHY objects

 

Yeah, but doesn't that need a spatial reference ID? Or would it
automatically know what to do?

 

On Thu, Dec 6, 2012 at 9:40 PM, Michal Zimmermann <zimmicz at gmail.com> wrote:

You can try to cast geography to geometry with
ST_Centroid(geography_column::geometry).


On 12/6/12, Ed Linde <edolinde at gmail.com> wrote:
> Hi All,
> I have a huge bunch of scattered lat/long coordinates stored as GEOGRAPHY
> type. I would now like to cluster some of them and
> compute their centroids.
> I know there is a centroid computation function in Postgis, but it seems
to
> only work on a geometry type.
> The lat/long coordinates are spread all across the globe and hence I
cannot
> convert it to local UTM formats because there is a discrepancy when going
> across different zones!
> Any workarounds?
>
> Thanks,
> Ed
>



--
Michal Zimmermann (zimmi)
WWW: http://www.zimmi.cz
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121206/1ef52afc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3772 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121206/1ef52afc/attachment.png>


More information about the postgis-users mailing list