Help needed: straight-line distance to Coast from a point on island

31 views
Skip to first unread message

Jason Williams

unread,
Aug 5, 2022, 12:15:54 AM8/5/22
to SpatiaLite Users
The island is a polygon, and the point is inside the polygon.
Need to calculate the  straight-line distance 
I can think of a way: 

step 1. Get closest point :
 select ST_ClosestPoint(ST_Boundary(SetSRID(geometry, 26917)), srctable.srcpt)  as ptNearest
step 2. Get the distance:

Math.Sqrt(Math.Pow(ptSrc.X - ptNearest.X, 2) + Math.Pow(ptSrc.Y - ptNearest.Y, 2));

Is there a better way?


mj10777

unread,
Aug 5, 2022, 12:41:18 AM8/5/22
to SpatiaLite Users
Yes.

Again, study the Cookbook (Version 5.0.0):

SpatiaLite Cookbook Topics


The answer you are looking for is contained in part 3 of recipe #17: Railways vs Populated Places

Reply all
Reply to author
Forward
0 new messages