On Wed, 3 Mar 2021 at 04:59, C Hamilton <adenacult...@gmail.com> wrote: > > I just had a user tell me he had to go back to ArcGIS so that he could use > the Select by Location function and specify a distance from the feature. He > could not believe that it was not available in QGIS. See > > https://desktop.arcgis.com/en/arcmap/10.3/map/working-with-layers/using-select-by-location.htm > > What he is looking for is the "Are within a distance of" operator. Am I > missing it in QGIS if not this is a really important operator to include. I > know you can always prebuffer the layer, but for an analyst who does this > regularly ours will go back to using ArcGIS. > > Would this be fairly easy to implement?
Reasonably so - the bulk of the required changes would all sit within QgsLocationBasedAlgorithm , specifically in QgsLocationBasedAlgorithm::processByIteratingOverTargetSource and QgsLocationBasedAlgorithm::processByIteratingOverIntersectSource (there's two code paths there, and the one called will depend on whether its more efficient to iterate over the first or second layer -- this dual-logic approach is why these algorithms and join by location are much faster then the intersection algorithm as previously discussed!). In both of these you'd basically expand out the size of the bounding box used to request matching features via QgsRectangle::grow (so the larger bounding box is handed off to the underlying data provider spatial index for filtering), and then change the "isMatch" test to use engine->distance( .... ) <= buffer distance. (Might also be worth first testing if the geometries intersect before calculating the distance as it may be more efficient to do this, but would need to be tested to verify.). On GEOS >= 3.9 based builds the distance(... ) check is optimised and uses indexes, so it should be very fast to perform this check! (As opposed to the inefficient "buffer the geometries" approach). Basically we'd want to follow PostGIS ST_DWithin approach, not a ST_Intersects(ST_Buffer(...)) approach. If I was quoting for a customer I'd estimate 5 hours total for the change, but of course YMMV. Nyall > > Calvin > _______________________________________________ > QGIS-Developer mailing list > qgis-develo...@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer _______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user