[postgis-users] Point to Polygon edge ST_DWithin

Nicklas Avén nicklas.aven at jordogskog.no
Thu Feb 16 13:30:23 PST 2012


Hallo

What you do is htat you use the linestrings defining the polygons 
instead of the polygon instead in the ST_Dwithin statement.

Then you can also us ST_Closestpoint to find a line between the point 
and the closest point on the edge. This line can you use in ST_Azimuth.

If your polygons have inner rings you can use ST_DumpRings to take also 
those in account. If you only want to use the exterior rings you can 
omit that part. But if there is multipolygons, you should use ST_Dump 
instead just to get single polygons.



SELECT ST_Azimuth(point_table.the_geom, ST_ClosestPoint(edges.the_geom, 
point_table.the_geom)) as the_azimuth FROM
(SELECT ST_ExteriorRing((ST_DumpRings(the_geom)).geom) as the_geom FROM 
polygons_table) edges
, point_table
WHERE ST_DWithin(edges.the_geom, point_table.the_geom, 10000);


HTH

Nicklas










On 02/16/2012 04:53 PM, uk52rob wrote:
>
> Hi,
>
> I need to create a WHERE statement which is true if a point is within 
> 10000 metres of the closest edge of a polygon (EPSG:27700).
>
> I have this working fine for point to point queries, but I am 
> struggling with point to polygon.  I also need to perform ST_Azimuth 
> on the resulting data to return a bearing.
>
> Has anyone got any ideas?
>
> Thanks
>
>
>
> _______________________________________________
> 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/20120216/a9265d1a/attachment.html>


More information about the postgis-users mailing list