Sunday, 1 December 2019

qgis - Improving our spatial data by calculating "Close to Coastline", "Close to Park", "Close to Stadium" etc



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.


enter image description here


Now you can do the 'Distance to nearest hub' and calculate the shortest path for your input-points. Set the hub layer name attribute



enter image description here


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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...