[postgis-users] Re: maximum distance between a POINT and POLYGON

Sufficool, Stanley ssufficool at rov.sbcounty.gov
Fri Feb 20 08:50:17 PST 2009


>From your initial approach, the following should work. I don't use
spheroid projections, so this was only tested with st_distance. I fudged
in the distance_spheroid. You may also want to replace the st_centroid
function with your field "geometry_centroid".
 
select max(myDistance) FROM 
(
    SELECT distance_spheroid(
        st_centroid(geometry_zone),
         ST_PointN(ST_ExteriorRing(geometry_zone), 
          generate_series(1,st_npoints(ST_ExteriorRing(geometry_zone)))
    ,'SPHEROID["WGS 84",6378137,298.257223563]'
    ) as myDistance
    from "208_1_26624_zones"
) as table01
 
 


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of My
Pid
Sent: Thursday, February 19, 2009 4:14 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Re: maximum distance between a POINT and
POLYGON


Hello again,

I found the generate_series function (yes i am a newbie!) and I can use
it in order to calculate the distance between
 my centroid (geometry_centroid) and my polygon (geometry_zone) with the
following request


SELECT
(distance_spheroid(geometry_centroid,ST_AsText(ST_PointN(ExteriorRing(ge
ometry_zone), generate_series(1,(SELECT npoints(geometry_zone) FROM
"208_1_26624_zones" WHERE "cellID"='1')))), 'SPHEROID["WGS
84",6378137,298.257223563]')) as d FROM "208_1_26624_zones" WHERE
"cellID"='1';

Now I can't use the max function because of the following error:
"set-valued function called in context that cannot accept a set"
when I use

SELECT
max(distance_spheroid(geometry_centroid,ST_AsText(ST_PointN(ExteriorRing
(geometry_zone), generate_series(1,(SELECT npoints(geometry_zone) FROM
"208_1_26624_zones" WHERE "cellID"='1')))), 'SPHEROID["WGS
84",6378137,298.257223563]')) as d FROM "208_1_26624_zones" WHERE
"cellID"='1';


any idea ?

thanks!
Nick



2009/2/18 My Pid <mamat750 at gmail.com>


Hello,

I would like to know how I could get the maximum distance between a
POINT and a POLYGON.
(the POINT i am talking about here is in fact the ST_Centroid of the
mentionned POLYGON)

I looked for a function that transform my POLYGON into several POINT but
without success.

I am working with longitude, latitude, altitude for POINT
It is really the max distance that I am looking for (not the minimum
distance.)
and "accuracy" is important to me.

thanks in advance for your help !

regards,
Nick





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090220/849a4e6b/attachment.html>


More information about the postgis-users mailing list