A quick background for context is maybe helpful for this. Essentially we have "vacation rentals" and I would like to add additional data to them automatically. We create booking websites for customers who have very niche sites, for example,
- "Pet Friendly" rentals.
- "Olympic Cottages"
- "Surfing Adventure Lettings".
Quite often each of our customers always ask the same questions,
"It would be awesome if we could plot the distance and sort properties based on their relative distance from XYZ".
Usually XYZ is something like a list of dog friendly beaches, or cycle tracks, or wine vinyards. So esesntially points of interests which are easily definable. In those cases, we've always just asked the customer to provide a list of the lat/lngs of every possible "point of interest" that they would like us to calculate distance from".
More recently we've been asked to include "Close to Coastline".
What I want is to come up with a standard way of automating this. My ideas so far are to create a shapefile. For example, let's say we wanted to do "Close to Coastline", we could use something like
http://www.naturalearthdata.com/downloads/10m-physical-vectors/
At this point, I'm somewhat stuck in knowing how would be most efficient to calculate the distance from the edge of the coastline.
I'm thinking about being able to just create/add a shapefile per "concept" that the customer wants us to use for their product. But then do not know the process/tools available to me to know distance from each edge, or vector point.
Answer
In your case I think the easiest sollution is to use the algorithm 'Distance to nearest hub'. This can be found under processing > processing toolbox.
This algorithm works best from point to point. So you have to convert all your line and polygonlayers to points first. This can be done with the algorithm 'convert line to points'. You have to set a minimum distance (for example: 10 meters). This well create points every 10 meters along your coastline.
Now you can do the 'Distance to nearest hub' and calculate the shortest path for your input-points. Set the hub layer name attribute
Now you can calculate the length of each hub-segment en select the shortest.
If you put this all together in a model, it will just take one step to calculate the same for different layers.
No comments:
Post a Comment