I have say, 6,000 polygons roughly 25 acres each, all touching one another, basically a grid but with irregular shapes.

Using QGIS, how do I start with one shape then in an automated process, select only those shapes that aren't within 300 feet?

So of all 6,000 shapes how many can be "used" based on the fact they aren't within 300 feet of each other.


If I'm not wrong, you ask that how many times a polygon is selected as not within buffer of another polygon. (as completely or partially outside of buffer)

Add a field to table named "How_Many", populate with zeros. And run.

layer = iface.activeLayer()
vpr = layer.dataProvider()
feat_list = list(layer.getFeatures())
field_index = layer.fieldNameIndex("How_Many")

for feat_1 in feat_list:
    buf = feat_1.geometry().buffer(300, 100)
    for feat_2 in layer.getFeatures():
        no = not feat_2.geometry().within(buf) 
        if no:
            value = feat_2.attribute("How_Many")
            value += 1

                feat_2.id():{field_index: value}})

Your Answer

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

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