This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Overpass: check double node elements nearby

0
1

For example trees on nodes natural=tree. Most trees have a distance to the other tree. They a planted line or random but mostly with a space between them. If I want to see only the trees that are close by, say less then 5 meter.

[out:json];

(
  node["natural"="tree"]({{bbox}});
)->.a;

(
  node(around.a:5)["natural"="tree"];
);

out body;
>;
out skel qt;

This give all trees even with around.a:0

Of course the node natural=tree is the base, the base is always a distance of 0m. Only to a other node should be calculated.

How to fix this?

asked 05 Sep '18, 00:53

Allroads's gravatar image

Allroads
222161725
accept rate: 10%

edited 05 Sep '18, 15:16


One Answer:

2

You need to evaluate the trees one at a time and subtract the base tree from the around result:

[out:json];
(
  node["natural"="tree"]({{bbox}});
)->.a;
foreach.a->.tree(
  node(around.tree:10)["natural"="tree"];
  (._; - .tree;) -> .others;
  (.collect; .others;) ->.collect;
);
.collect out;

(setting around.tree to 5 returns 0 results at the location there)

answered 05 Sep '18, 12:47

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Thanks, it works. A little slow, when I take a bigger area or a adm_level.

(05 Sep '18, 15:18) Allroads

Source code available on GitHub .