[postgis-tickets] [PostGIS] #2951: ST_Centroid for geography

PostGIS trac at osgeo.org
Tue Aug 1 08:57:35 PDT 2017


#2951: ST_Centroid for geography
--------------------------+---------------------------
  Reporter:  Mike Toews   |      Owner:  robe
      Type:  enhancement  |     Status:  new
  Priority:  medium       |  Milestone:  PostGIS 2.4.0
 Component:  liblwgeom    |    Version:
Resolution:               |   Keywords:
--------------------------+---------------------------

Comment (by robe):

 Okay crash is gone, but something is not quite right about these
 calculations.  Seems to work okay when I do buffers, answers are as
 expected.

 But here is one that is glaringly wrong.


 {{{
 SELECT ST_AsText(ST_Centroid(geog))
 FROM ST_GeogFromText('LINESTRING(-71.0846005 42.3971753,-71.0846078
 42.3971502,-71.0847687 42.396707,-71.0847746 42.3966641,-71.0847638
 42.3966281,-71.0847404 42.3965966,-71.0847056 42.3965679,-71.0846586
 42.3965386)') As f(geog);

 Output is:
 POINT(-0.000955750185501768 0.00761666977447508)
 }}}


 note how the centroid is no where near the line.  I would expect the
 answer to be similar to what I get when I transform to state plane meters
 to do the computation and then transform back.


 {{{

 SELECT
 ST_AsText(ST_Transform(ST_Centroid(ST_Transform(geog::geometry,26986)),4326))
 FROM ST_GeogFromText('LINESTRING(-71.0846005 42.3971753,-71.0846078
 42.3971502,-71.0847687 42.396707,-71.0847746 42.3966641,-71.0847638
 42.3966281,-71.0847404 42.3965966,-71.0847056 42.3965679,-71.0846586
 42.3965386)') As f(geog);

 -- outputs
 POINT(-71.084699611775 42.3968457764674)
 }}}

 I've attached screen shot.

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/2951#comment:11>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list