How to find multiple objects with same tag around eachother with Overpass Turbo

For example, I want to find only factories with 2 or more chimneys. Theoretically, I could search for a chimney around a chimney.

nwr["man_made"="chimney"]({{bbox}}) -> .a;
nwr["man_made"="chimney"](around.a:10);

But in practice, it is impossible since “.a” does not differ from the second statement. I just will have the very same objects.

Is there any way to search for objects that are NOT around? Or maybe I could somehow exclude all objects that are “around:0” from the result.

Explanation:
foreach loops over each element in chimneys. For each chimney we take the difference of the set of chimneys surrounding that chimney and the set with only that chimney. The objects in this difference are merged into the result set.

1 Like

The trick is to remove each individual (.chimney) from “.a” in the second statement.
Chimneys around chimneys.

Note @spaanse’s version returns fewer chimneys. Unsure why at the moment.
https://overpass-turbo.eu/s/1EQP

Is it possible to do it in Overpass Turbo or I should use something else?