[postgis-users] Re: maximum distance between a POINT and POLYGON
My Pid
mamat750 at gmail.com
Sun Feb 22 11:59:20 PST 2009
Kevin,
Thanks a lot for your "geometry to text" advice.
It works perfectly now
Nick
-----------------------------------------------------------------------------------------------------------
Message: 30
Date: Thu, 19 Feb 2009 08:51:21 -0800
From: Kevin Neufeld <kneufeld at refractions.net>
Subject: Re: [postgis-users] Re: maximum distance between a POINT and
POLYGON
To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
Message-ID: <499D8E09.8000205 at refractions.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Try moving your query into a subquery and then taking the max distance.
Also, you can probably drop the subquery you
put as a parameter to the generate_series call. Why are you converting the
geometry to text, then back to a geometry again?
ie.
SELECT "cellID", max(dist)
FROM (
-- Your query here, but also select the cellID to group on
SELECT
cellID,
distance_spheroid(
geometry_centroid,
ST_PointN(
ExteriorRing(geometry_zone),
generate_series(1, ST_NPoints(geometry_zone))
),
'SPHEROID["WGS 84",6378137,298.257223563]'
) AS dist
FROM "208_1_26624_zones"
WHERE > "cellID"='1'
) AS foo
GROUP BY "cellID";
-- Kevin
My Pid wrote:
> 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(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';
>
> 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 <mailto: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
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090222/ba6e9718/attachment.html>
More information about the postgis-users
mailing list