You can easily do that using SQL. Since QGIS 2.14 you can create Virtual Layers based on SQL Queries to load layers on your canvas. I believe using the following query will work:
select t.origin_gid, t.target_gid, t.target_value, t.geometry FROM (Select f.gid as origin_gid, g.gid as target_gid, g.value as target_value, g.geometry FROM layer_1 as f, layer_1 as g WHERE f.gid >= g.gid and st_within(g.geometry, st_buffer(f.geometry, f.value)) ORDER BY f.gid, g.value ASC) as t group by t.origin_gid Alexandre Neto Niccolò Marchi <sciurusurba...@hotmail.it> escreveu no dia sexta, 12/08/2016 às 12:24: > Hi all, > > I have a set of projected spatial points (id, x, y, dist, value) that > needs to be filtered. For each point I have to find the other ones falling > within a variable distance. For each selection, I need only the one with > the maximum value or, if duplicated, keeping just one. > > I tried to check the available tools and I found out what follows: > > - A simpler possibility would be to use the “Select by > expression”, but I’m not that familiar with the syntax and I ended up with > [clearly non-working]: CASE WHEN distance($currentfeature)<”dist” THEN > max(“value”) END > > - Another possibility would be to improve the following R code, > available online (thanks to the author) > > Any (R, Python, else) suggestion? > > > > > > ##Layer=vector > > ##ID=Field Layer > > ##distance= Field Layer > > ##Output= output vector > > library(rgeos) > > library(sp) > > library(spdep) > > > > coordi <- as.matrix(coordinates(Layer)) > > tram_nb <- dnearneigh(coordi, d1 = 0, d2 = distance,row.names=Layer[[ID]]) > > tram_nb<-as.data.frame(card(tram_nb)) > > tram<-cbind(as.vector(Layer[[ID]]), tram_nb) > > Coord<-cbind() > > n<-length(Layer[[ID]]) > > for(i in 1:n){ > > if (tram[i,2]!=0 ){ Coord <-rbind(Coord,cbind(coordi[i,1], > coordi[i,2],as.vector(Layer[[ID]])[i])) > > } > > } > > x<-as.numeric(Coord[,1]) > > y<-as.numeric(Coord[,2]) > > X<-cbind(x,y) > > matrix<-as.matrix(X) > > matrix<-SpatialPointsDataFrame(matrix,as.data.frame(Coord),proj4string=CRS(Layer)) > > Output=matrix > > > > Thank you in advance for your help! > > > > All the best, > > > > Nic > > > > > > > > > > > > > > > > > _______________________________________________ > Qgis-user mailing list > Qgis-user@lists.osgeo.org > List info: http://lists.osgeo.org/mailman/listinfo/qgis-user > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user -- Alexandre Neto --------------------- @AlexNetoGeo http://sigsemgrilhetas.wordpress.com http://gisunchained.wordpress.com
_______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user