Saturday, 14 July 2018

network analyst - How to compute areas of influence in QGIS?


I am trying to create a polygon layer showing polygons that correspond to a closest store.


For a set of 30 store locations, the result should be a polygon layer with 30 features, one for each store. Each feature will represent an area where it's corresponding store is the closest. For example, an address within polygon 12 means that store 12 is the closest.


I have my store locations layer and OSM streets layer with max speed column. The resulting polygon layer should be based on the OSM streets layer and not simply linear areas.


The idea is that given a fixed set of stores and roads, the closest store should remain constant at any given point on a map. Thus, I am hoping that the resulting polygon layer will be gapless.


This video of Maptitude software provides a perfect example of what I'm trying to accomplish (fast forward to 1:55 of the video). Alternatively, see the image below for an example:


Maptitude Areas Closest to Hospital


For each hospital, there is a corresponding area where anything within that area is closest to the hospital located within that area.


How can I replicate this using QGIS?




Answer



the grass algorithm v.net.alloc can produce the subnets - you can call it from the Processing toolbox (tested in QGIS 2.16)


You'll need a point layer (for facilities) and a lines layer with costs (either time/length). It'll create a new line layer with a field called cat added, which will be the id of the nearest facility.


Here's an example based on walking distance to the nearest pub. Each line segment is coloured by cat using random colours:-


v.net.alloc example


Note that sometimes two adjacent pubs' road networks are given very similar colours; if you label them, you'll see it has actually worked.


As to getting gap-free polygons like you show above, I'm stumped. If you 'extract nodes' on the results and apply 'Convex Hull' (grouping by cat), there will be gaps and overlaps.


EDIT


you can indeed get the desired result. As you suggested in your comment, you can do the following..




  • run Extract nodes on the output of v.net.alloc

  • run Voronoi polygons on the extract nodes layer

  • run Fixed distance buffer on that to make sure polygons overlap (e.g buffer by 1 meter)

  • run Dissolve on the buffered layer, using the field 'cat'


Here's the result...it's not perfect, you'll sometimes see parts of the road network stray into neighbouring polygons.


enter image description here


There's a 'trap' in the new 2.16 GUI for dissolve. I set the field, but it seemed to dissolve everything. You need to remember to uncheck the 'dissolve all' checkbox, or the field setting is ignored.


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...