0

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.

1

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)

At first, I thought it was complicated. Then I tried something. And it is not so complicated.

Add a field to table named "How_Many", populate with zeros. And run. (in QGIS 2.18)

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

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

I tried for four polygons. It works. Some changes are required to work in QGIS3.

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.