QGIS Expression – Select by Expression and Buffer Selection in QGIS

expressionqgis

I want to select points 2 and 3 with a 'selection with expression' in QGIS 3.4. I want to do this by using the buffer function in the expression builder.

I already managed to create a separate buffer and then selecting points that are overlapped by the buffers.

I expect that the expression will select points 2 & 3. The expression buffer( $geometry, 5000) is not giving the result i expect.

Buffered selection

Best Answer

Thanks to the suggestion by @she_weeds, I found a much better solution. This method can be performed entirely in the Select by Expression tool, without creating any additional layers.

Use the collect function to combine the church points into a multipoint geometry. Use this multipoint geometry in the intersects function. Because we're using collect on a different layer, we have to put it inside the aggregate() function, like so:

intersects($geometry, buffer(aggregate('churches','collect',$geometry),5000))
Related Question