Overpass-API icon indicating copy to clipboard operation
Overpass-API copied to clipboard

Clip results to a specified area

Open tordans opened this issue 4 years ago • 1 comments

Goal: I would like to clip the output of a query to the area that I specified for the query.

Right now, the ways that are selected by the query extend the selected area; its always the whole way until there is a split in the way.

This has a few consequences:

  • When using the overpass feature that calculates length, the lengths is larger than the requested area
  • Data needs to be clipped in external tools in order to display them on a map with clear borders (And it looks like there are no js-based solutions for this available(?) – Have to check out this one)

Clip to bbox:

https://github.com/drolbr/Overpass-API/issues/249#issuecomment-168372746 explains, that it is possible to clip the output to a bbox.

[out:json][timeout:25];
( 
  area["boundary"="administrative"]["admin_level"="8"]["name"="Zeuthen"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Eichwalde"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Schulzendorf"];
)->.searchArea;
(
  way["highway"](area.searchArea);
);
out geom({{bbox}}) meta;

Feature request: Clip to area:

Ideally, something like this would work …

[out:json][timeout:25];
( 
  area["boundary"="administrative"]["admin_level"="8"]["name"="Zeuthen"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Eichwalde"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Schulzendorf"];
)->.searchArea;
(
  way["highway"](area.searchArea);
);
out geom(area.searchArea) meta;

tordans avatar Nov 11 '21 15:11 tordans

Note you can do some clipping by only returning the nodes that are inside the area:

[out:json][timeout:25];
( 
  area["boundary"="administrative"]["admin_level"="8"]["name"="Zeuthen"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Eichwalde"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Schulzendorf"];
)->.searchArea;
(
  way["highway"](area.searchArea);
);
out;
node(w)(area.searchArea);
out skel qt;

naomap avatar Jan 21 '23 17:01 naomap