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?

1

2 Answers 2

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.

1
  • 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, 2016 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

1
  • 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, 2019 at 8:27

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