1

I have a point layer and want to know the distance to the coastline (line or polygon layer) from each point in a series of directions (0, 10, 20, 30 degrees, etc).

I have found this python script (How to visualize updating lines of bearing from a point) that draws radial lines from a point. Using those I can find intersection points using the intersect tool in Geoprocessing. then, I can manually figure out which point along each line is the closest to the initial point... This is not very straightforward and I have several hundred point...

It seems it should be easy to code a python script... any easy solutions?

closed as off-topic by Jochen Schwarze, LaughU, PolyGeo Feb 15 at 7:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – Jochen Schwarze, LaughU, PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

2

A strikingly similar Q/A is here. Their question discusses finding the shortest path from a point to a coastline and the answer to their question gives a bit more detail on how to use the GRASS v.distance tool. Give it a shot.

Basically, input your points as the 'from' layer and the coast as the 'to' layer. A new vector map can be created with lines connecting to the nearest points on the to layer.

I know you initially asked about using a series of directions, but further down the question you mention that you will 'manually figure out which point along each line is the closest to the initial point.' So, the above should answer the 'closest line from point to coast' while below is a possible programmatic workflow for using the code sample you linked.

1) Clip the radial lines at the coastline

2) Do a series of selections to find the lines touching both the point and the coastline

2.a) Select those lines touching the coastline

2.b) Using 2.a selection set: select those lines that touch the point

3) Sort that subset of lines based on length

4) Line at the top is the shortest from point to coastline. 

You can programatically loop through each point creating the spokes for each one and running this process on each point.

  • I tried clipping radial lines at the coastline, but that didn't seem to work. Instead, I used qgis:lineintersections to create a point shapefile with the intersections (note that there are more than one intersection per direction because of islands), then qgis:distancematrix to figure out the distances between initial point and all the intersection points in all the directions (direction is an attribute). This can all be done in a loop. the only part that I can't figure out is how to pick the shortest distance for each direction... any min function by attribute I could use? – JSlauzon Jun 21 '16 at 17:59
-1

Yes, you can get the distance to coast (in the continental US) but using this website: https://www.distancetocoast.com/?search=Coconut+Grove%2C+Miami%2C+FL%2C+USA

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – LaughU Feb 15 at 8:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.