My problem: I have a single shapefile from a habitat-survey and need to select all hedge-features that are enclosed in meadows.The features that are to be selected were created by filling rings. Select by attribute does not work since not all hedges are within meadows. I've tried the Spatial Query Plugin's 'within' and 'contains' option after duplicating the layer, but since the features do not overlap, the plugin finds no result. The 'touches' option gets results, but unfortunately also selects neighbouring features which I don't need.

How can I select only the enclosed objects without having to do it manually?

1 Answer 1


I was able to solve the problem with a workaround:

I duplicated the layer in question twice and removed all features but the hedges in one duplicate and all but the meadows in the other.

Then I used the 'Polygon to Line' tool on both and created layers with only the boundaries of the features.

I used 'intersect' on the line-layers and was left with the common boundaries of meadows and hedges. After calculating the lengths of all features in both the hedge-layer and the shared-boundary-layer I spatial-joined them using the 'sum'-option on the shared-layer and thus got a hedge-layer that contained both a column with the original length as well as the length it shares with a meadow.

Then I used the field calculator to create a new field with the ratio of shared length to overall length. All features with a ratio of 1 are completely enclosed by meadows.

Your Answer

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

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