# Delineating service catchment in QGIS?

I have a set of locations each representing a service capacity. I also have a polygonal layer with each polygon representing local demand for that service. For each location, I would like to define its service catchment by summing up the demand values from its nearest polygons until they meet the service capacity of the location. I thought it might be easier to rasterize the demand layer and then do some cost distance assessment but I can't figure out how to do this by summing the attribute value to meet the local service value.

Image 1 shows the data I have, The location example has a service capacity of 1100 and the polygons represent local demand. Image 2 shows how I have manually selected polygons summing to close the capacity, this would represent the service catchment.Image 3 shows a rasterized version of demand

.

Anyone have an idea how this could be achieved?

This sounds like a problem for PyQGIS. I'm a total Python newb, so it would take me a very long time to actually code this, but I outlined a possible solution in pseudocode.

# Add a unique identifier field to the point layer (if it doesn't already have one)
# Add a field to the polygon layer, ServiceLoc, to keep track of which service location is associated with each polygon.

# create a number variable, totaldemand
# create a number variable, buffersize

# for each point in the service location layer, do the following:

# while totaldemand is less than the service capacity of the current point, do the following:
# increase buffersize by some value (approximately the average width of shapes in the polygon layer)
# create a buffer around the current point of size buffersize
# select all polygons that intersect the buffer
# set totaldemand equal to the sum of local demand values in the intersected polygons
# once totaldemand is equal to or greater than the service capacity, change the ServiceLoc of all selected polygons to the unique identifier of the current point
# clear the selection


The same basic plan could be used to set up a model in the graphical modeler.