I want to eliminate any overlaps in a single vector layer with many buffers. I have a raster file of population density and picking out areas over some threshold. I need to cover those points with a fixed size buffer to show satellite beam cover but don't want redundant or overlapping buffers because that would waste beams (don't want to just dissolve them into one to show coverage).

enter image description here

I know about the topology checker to create rules for overlap but this seems impractical to manually resolve all the errors on large scale.

Is there a better way?

I've also seen things about using intersect but I'm not exactly clear on how I would made a decision based on that. I'm new to GIS.

Here is the code to get to this point:

from qgis.analysis import QgsGeometryAnalyzer


layer = iface.activeLayer()

provider = layer.dataProvider()

extent = layer.extent()
xmin,ymin,xmax,ymax = extent.toRectF().getCoords()
rows = layer.height()
cols = layer.width()
xSize = layer.rasterUnitsPerPixelX()
ySize = layer.rasterUnitsPerPixelY()

block = provider.block(1, extent, cols, rows)

xinit = xmin + xSize/2
yinit = ymax - ySize/2

x = xinit
y = yinit

points = []
values = []

for i in range(rows):
    for j in range(cols):
        value = block.value(i,j)
        if value > 3000:
        x += xSize
    y -= ySize
    x = xinit

epsg = layer.crs().postgisSrid()

uri = "Point?crs=epsg:" + str(epsg) + "&field=id:integer&field=value:integer""&index=yes"

mem_layer = QgsVectorLayer(uri, 'point', 'memory')

prov = mem_layer.dataProvider()

feats = [ QgsFeature() for i in range(len(points)) ]

for i, feat in enumerate(feats):
    feat.setAttributes([i, values[i]])



QgsGeometryAnalyzer().buffer(mem_layer, env + "output.shp", 1.5, False, False, -1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.