7

I have a point layer in QGIS. Each point represents a tree and each tree has information about its height as an attribute. I would like to build a query/expression to select all those trees that have an other tree higher than 7 meters within their 20-meter-buffer (20 meter radius).

I managed to do this "manually" by creating a 20-meter-buffer around all trees higher than 7 meters (after the selection of the trees higher than 7 meters) and then selected the ones within the buffer but I was wondering if its possible with a query/expression. (maybe with a bit more complex one)

Unfortunately I do not have PostGIS so this should be done with Select by expression or Query Builder if possible.

(It would be also helpful to know if it's simply impossible)

  • I posted an answer earlier on a similar problem (well, it's not exactly the same but it can easily be modified to fit your condition). I guess it's possible with the QGIS query builder, however i'm not really used to it. Without using PostGIS you can easily put your data in Spatialite format (you can create a memory DB just for fetching the result of this computation) and make spatially enabled requests through the QGIS DB manager. I can post a query for SpatiaLite if you are ok to load your data this way. – mgc Feb 5 '16 at 22:04
11

This can be done using the Processing Graphical Modeler to set up a custom chain. Here's a pic:

enter image description here

From left to right we have three inputs - the tree layer (a Vector Layer Input Object), the buffer size (a Numeric Input) and the tree height (a String Input). The tree layer is then selected by its height attribute. The selected trees are then buffered by the value of the buffer_width input - this is saved as a layer treebuff (remove that output if you don't need it, I just used it for checking). Then the Select By Location process sets the selection to those trees inside the buffer region (set the first input to the trees, the second to the buffer, and the predicate to "contains")

Here's the resulting output:

enter image description here

Large trees are drawn large, and you can see the buffer zone and the selection now includes the large trees and their neighbours within the buffer.

  • You could end up the process by deleting the treebuff layer once it has been used to produce inrange layer. By the way, could it be possible to operate just a selection of matching trees within the tree layer, as the question mentions a selection of trees and not a new layer containing matching trees? – wiltomap Feb 6 '16 at 17:12
  • If you don't want the buffer layer then you can just remove it from the output in the model. I put it in there as an extra output to make sure the thing was doing what I expected. Good point about the selection though... There is a "Select by..." operator that can do intersections... If I had a free hour... – Spacedman Feb 6 '16 at 18:35
  • @wiltomap found an hour :) model now returns a selection instead of a new layer! – Spacedman Feb 7 '16 at 21:37
  • @Spacedman Thank you very much! Especially for the detailed instructions. I haven't used Graphical Modeler and it's pretty great. For some reason selection hasn't worked for me at the end of the process, but I keep trying as your model seems correct. (I think something went wrong on my side.) – Skye Feb 9 '16 at 23:11

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.