[postgis-users] How to get the centroid of an bounding box using st_extent

Paul Ramsey pramsey at refractions.net
Tue Sep 18 21:59:03 PDT 2007


Well, clearly there's a bug to be fixed.
In the meanwhile, since these are just boxes,

makepoint((minx+maxx)/2, (miny+maxy)/2)

P.

On 18-Sep-07, at 8:56 PM, Charlie Savage wrote:

> It turns out that st_extent is hundreds of times faster than  
> Envelope. But I run into a problem when using it:
>
> select st_extent('POINT(10 10)')
> "BOX(10 10,10 10)"
>
> But if you do this:
>
> select asText(centroid(st_extent('POINT(10 10)')))
> "GEOMETRYCOLLECTION EMPTY"
>
>
> Which is the same issue I mentioned a couple weeks ago where  
> Envelope('POINT(10 10)') doesn't return a point like it should.
>
> So I'd like to use st_extent, but a need a way to get a valid point  
> that represents the center of the bounds instead of an empty  
> collection.  How?
>
> Charlie
> _______________________________________________
> 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