Search code examples
overpass-api

Filtering results from is_in() OverPass query


I'm new with OverPass API.

I would like to get the country element where a certain point is contained.

As a first step I tried this:

is_in(48.856089,2.29789);
out;

It gives me all the areas which contain the given coordinate, including regions, provinces...

So now, I would like to filter the country only. In the results, I can see that the country element is determined by the admin_level attribute, which must be equal to 2.

So, in order to filter my first request, I tried this:

is_in(48.856089,2.29789)[admin_level="2"];
out;

But with OverPass Turbo, it gives me the following error:

Error: line 1: parse error: ';' expected - '[' found.

I read that areas are an extended data type (compared to nodes, ways, and relations). Is it the reason why I can't filter my results?

How can I filter results from the is_in query, by [admin_level="2"]?


Solution

  • You cannot combine is_in with any additional filter criteria. The proper way to do this is as follows, where ._ refers to the area result returned by is_in.

    is_in(48.856089,2.29789);area._[admin_level="2"];
    out;