Direction to nearest point of a polygon

13 views
Skip to first unread message

ckgoo...@gmail.com

unread,
Oct 6, 2024, 4:01:02 PMOct 6
to spatiali...@googlegroups.com

Hi, I have a point and a polygon.  The point is outside of the polygon.  I can use ST_Distance to get a distance from the point to the nearest part of the polygon.  This is good.  Is there a way to find the direction from the point to the nearest point on the polygon?

 

I have looked at Azimuth but this expects two point geometries.

I have looked at InterpolatePoint but this expects a line geometry.

I tried CastToLinestring  on my polygon but it looks like I still get a null response.

And this is where I am stuck.

 

My only other thought is to do a little algorithm where I first find the distance between the point and the polygon.  Say I get 5000m as the result.  I could then make a circle of points around my original point of radius 1000m testing the distance for each.  I find the point with the minimum distance.  This point and my original point will then point towards the nearest point of the polygon and I can use the Azimuth function.

But I hope there is a simpler way.

 

Best,

Chris

Jukka Rahkonen

unread,
Oct 6, 2024, 4:10:55 PMOct 6
to SpatiaLite Users
Hi,

Have you tried ClosestPoint https://www.gaia-gis.it/gaia-sins/spatialite-sql-5.1.0.html to start with?

-Jukka Rahkonen-

ckgoo...@gmail.com

unread,
Oct 6, 2024, 4:42:45 PMOct 6
to spatiali...@googlegroups.com

Hi Jukka,

Thanks.  I didn’t see that one.  Looks just the thing I needed.

Many thanks, Chris

--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialite-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spatialite-users/07b1851a-50d9-4c4b-96fd-90b1ab75cc43n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages