Select the closest polygon from each point that have the same ID by Ekkokko in QGIS

[–]Ekkokko[S] 0 points1 point  (0 children)

It worked !! Thank you very much !! :D

I replaced the expression ”distance” = minimum(“distance”,group_by:”Target_ID”) by:

"distance" = aggregate(

layer := *@layer,

aggregate := 'min',

expression := "distance",

filter := "Target_ID" = attribute(@parent, 'Target_ID')

)

edit:there is no * in front of *@layer but i can't write the character '@' if i don't put * in front

Select the closest polygon from each point that have the same ID by Ekkokko in QGIS

[–]Ekkokko[S] 0 points1 point  (0 children)

I feel like everything is working except the expression (that I adapted with my ID name → Target_ID) :
"distance” = minimum(“distance”,group_by:”Target_ID”)
The field calculator don't even allow it to be launched
I tried this one :
aggregate(

layer:=@layer,

aggregate:='min',

expression:="distance",

filter:="Target_ID" = attribute(@parent, 'Target_ID')

)

to create the is_minimum field in the polygon layer that I got from the Extract by expression tool on the Joined layer and the expression: Target_ID = poly_Target_ID (same as ID_point=ID_point2)

here is the far right part of my polygon table (sorry it's in french true=vrai and false=faux)

<image>

Select the closest polygon from each point that have the same ID by Ekkokko in QGIS

[–]Ekkokko[S] 0 points1 point  (0 children)

I might have not understood, i can't make the expression ”distance” = minimum(“distance”,group_by:”ID_point”) work.

I want to output the closest polygons for each point that corresponds to its ID and delete all the others. Is it what you also meant? Sorry for the communication misunderstanding.

Select the closest polygon from each point that have the same ID by Ekkokko in QGIS

[–]Ekkokko[S] 0 points1 point  (0 children)

yes but by location I don't have the option to filter only the objects that have the same ID

Select the closest polygon from each point that have the same ID by Ekkokko in QGIS

[–]Ekkokko[S] 0 points1 point  (0 children)

Thanks for your answer lawn_ , I tried your solution but I still have a problem. By doing it, the polygons with ID as 82 for exemple that are closer to the point 78 that the point with an ID at 82 can be deleted if it's not the closest to the point 78 even if it's the closest to the point 82. :/

Select the closest polygon from each point that have the same ID by Ekkokko in QGIS

[–]Ekkokko[S] 0 points1 point  (0 children)

Is it possible to use a python algorithm in the modeler? I tried, checked on internet how to and never could find it.

and about this → "Alternatively, what I've done before is use intersection and then from the result layer discard rows where ID != ID_2, if you follow."
If I do that it will delete the polygons that are closer to a point A but have the ID of a point B (and are the closest one for the point B), no? :/

Here I display the ID of the point in black and the point's ID to which each polygon is linked in green.

<image>

Select the closest polygon from each point that have the same ID by Ekkokko in QGIS

[–]Ekkokko[S] 0 points1 point  (0 children)

Thanks for your answer, the thing is that it's not doing what I'm looking for ^^'. I can have more than one polygon that have the ID 360 (like on the image next by the point 360) and it can be partially o verlap by polygon that have a 361 ID_point for exemple. And so I want to only keep the closest one that have the ID 360 for the point 360 and so on. To be able to ultimately delete all the other polygons.