Wednesday, 15 July 2015

How to build a query/expression to select specific points within a buffer? (in QGIS)


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)



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...