This can be done with an 'Action'. I was able to do it with a bit of PyQGIS code. Change the point_layer_name in the snippet below to match your point name. Define the Action on the line layer. Here's how it works https://ibb.co/vP7KRDd
line_layer = QgsProject.instance().mapLayer('[% @layer_id %]') point_layer_name = 'points' fid = [% $id %] line_feature = line_layer.getFeature(fid) line_geometry = line_feature.geometry().buffer(40, 5) point_layer = QgsProject.instance().mapLayersByName(point_layer_name)[0] nearby_points = [p.id() for p in point_layer.getFeatures() if p.geometry().intersects(line_geometry) ] layer.selectByIds(nearby_points) [image: Logo] <https://spatialthoughts.com/> Ujaval Gandhi Spatial Thoughts mobile: +91-8095684687 email: uja...@spatialthoughts.com [image: LinkedIn icon] <https://www.linkedin.com/in/spatialthoughts/> [image: Twitter icon] <https://twitter.com/spatialthoughts> On Thu, Dec 24, 2020 at 8:02 PM Charles Dixon-Paver <char...@kartoza.com> wrote: > I was very interested to see if this was possible with qgis expressions > and symbology, and I got it to work with surprisingly little effort, albeit > with some issues [1]. > > I simply used the rule based symbology to highlight the relevant features > using an expression [2]. > > The expression I used was as follows: > > if( > distance($geometry, > geometry( > get_feature('Lines','fid','1') > ) > ) < 500 > ,true,false) > > One caveat is that the view does not automatically update when digitizing > a new vertice. As a result I needed to zoom in and out constantly to update > the symbol styles. This could probably be modified by using a layer action > though. > > Secondly, this expression is limited to a single feature in it's > current state. I'm not sure if anyone has a clever workaround for including > all geometries from another layer in an expression. > > Lastly, this only tracks actual features, not the cursor. > > There could be many other ways to achieve your result though, but I was > interested to see how well this would function so others might find the > result quite interesting. It's probably also quite usable for static styles > if the objective is just for mapmaking rather than a digitizing tool. > > [1] https://imgur.com/a/5J0dSt3 > [2] https://imgur.com/a/E043vO7 > > On Thu, 24 Dec 2020 at 15:31, Raffaele Ceretto <cerettoraffa...@gmail.com> > wrote: > >> I need a tool that allows me to draw a line and that at the same time >> highlights points within a certain distance (for example 40 meters). >> I have a map with hundreds of points, I would like when I draw a line >> what is nearby will light up. >> There is a specific tool to do this or a simple "magnet" function? >> Thank you for your help >> >> waiting for a reply >> >> regards >> >> Raffaele >> _______________________________________________ >> 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 >> > _______________________________________________ > 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 >
_______________________________________________ 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