12

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?

2 Answers 2

10

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.


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.

12
  • This is helpful and I can certainly use the result in my application. I will leave this open temporarily to see if there's a way to end up with polygons. Is it possible that using the Voroni Polygons tool somehow would help?
    – ge0m3try
    Commented Sep 6, 2016 at 22:48
  • a Voronoi on your facilities will only give an approximation, based on Euclidian distance "as the crow flies", so it effectively ignores your road network.
    – Steven Kay
    Commented Sep 7, 2016 at 20:34
  • I'm curious if I were to extract nodes on the v.net.alloc result, voroni that, and then dissolve the voting polygons based on the unique facility identifier. The size of the roads dataset is very large so I won't be able to test this quickly, but maybe in the meantime there will be some thoughts as to why this may not work out.
    – ge0m3try
    Commented Sep 9, 2016 at 18:40
  • actually, your hunch is right - just tried it.
    – Steven Kay
    Commented Sep 9, 2016 at 20:10
  • 2
    IMPORTANT NOTE: There's a few nuisances with this workflow that I've figured out how to overcome. Fixed distance buffer tool is not necessary. The SAGA Dissolve tool seems to be much faster than the QGIS equivalent. And, it also seems quicker to split the Voronoi layer by cat field, and then dissolve each area separately. Merge them back together. Then, run GRASS v.clean and choose the tool rmdupl to remove duplicate nodes. This is important otherwise other processes like clipping, spatial joining, all will not work properly on the merged dissolved voronoi lauyer.
    – ge0m3try
    Commented Feb 11, 2017 at 14:06
1

There is a repository I created to automate this, liberating all of the nuances buried in the answers comments: https://github.com/mattmarotta/QGIS-Subnet-Areas

I will leave the current answer as is, largely due to the contributions of @Steven Kay (many thanks!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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