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

Allow filtering by area size

Open tordans opened this issue 6 years ago • 6 comments
trafficstars

UseCase: Query all parks||gardens but only those areas that are above a certain size. Like bigger than 10 square meters.

Example:

[out:json];area[name="Berlin"];
(
  way["leisure"="garden"]["access"!~"no|private"](area);
  way["leisure"="park"]["access"!~"no|private"](area);
);
out center;

I don't want results like https://www.openstreetmap.org/way/634006146

This might be related to https://github.com/drolbr/Overpass-API/issues/464

tordans avatar Mar 08 '19 17:03 tordans

Workaround

There is a workaround for now: For simple area forms, the length of an area-way can be used to approximate the area size. I think this should be OK to use, at least for simple filters like I described above.

Before After
image image
(From the example above.) .
[out:json];
(
  way["leisure"="garden"]["access"!~"no|private"](if: length() > 10)({{bbox}});
  way["leisure"="park"]["access"!~"no|private"](if: length() > 10)({{bbox}});
);
out geom;
make stat total_length=sum(length()),section_lengths=set(length());
out;

The number 10 is picked by looking at the section_length list of a query without the if (or with if: … > 1), which, for the given example, would return:

{
  "type": "stat",
  "id": 1,
  "tags": {
    "total_length": "38.458",
    "section_lengths": "28.941;9.517"
  }
}

tordans avatar Sep 25 '21 18:09 tordans

Hi @tordans, I really hope this "area size" will be implemented. Thank you for the workaround :heart:

Binnette avatar Jan 20 '22 20:01 Binnette

i´d also would love to see the "area size" feature :)! but thanks anyway for the workaround!

pcace avatar Sep 05 '22 16:09 pcace

This would be so useful to be able to get the data directly without pre processing

baditaflorin avatar Jun 01 '23 13:06 baditaflorin

This functionality would be especially useful to OpenHistoricalMap. For example, you could query for the maximum extent of a city or an empire – a very basic fact in historiography – by filtering its boundary relations until you get a result set of only one. The perimeter is not necessarily very useful, because some boundaries have historically had very many enclaves and exclaves, not to mention scraggly borders.

1ec5 avatar Aug 24 '23 17:08 1ec5

For example, you could query for the maximum extent of a city or an empire – a very basic fact in historiography – by filtering its boundary relations until you get a result set of only one.

As a workaround, here’s a SPARQL query for the maximum extent of an empire in OpenHistoricalMap using QLever.

1ec5 avatar Jan 22 '24 02:01 1ec5