Search code examples
openstreetmapoverpass-api

OSM API Overpass


I am trying to pull all glaciers as entered in OSM in a given country but am noticing that I am only pulling a fraction of what is available. For example, when I run this following code:

import overpass from shapely.geometry 
import shape, Polygon
api = overpass.API()
api = overpass.API(endpoint="https://overpass.myserver/interpreter")
api = overpass.API(timeout=600)
query = 'area["ISO3166-1"="IS][admin_level=2];(way["natural"="glacier"](area););'
result = api.get(query, verbosity='geom')
import geopandas
results = geopandas.GeoDataFrame.from_features(result['features'])

The result has 132 features and appears as so:

Iceland Glaciers

I know this is missing one large glacier (Vatnajökull) which does appear in OSM under osm id 406429.

Any thoughts as to why this is not appearing as a result from my query?


Solution

  • OSM Wiki tag documentation is a helpful starting point when writing Overpass queries. Here is the documentation for natural=glacier. The tag/value is applied to nodes and closed ways based on the documentation and also appears to apply to relations based on community preference (even though this is discouraged in the documentation).

    To query for nodes, ways, and relations, you can use the abbreviation nwr instead of the union (node[natural=glacier];way[natural=glacier];relation[natural=glacier];);. As a side note, you can drop admin_level=2 since ISO3166-1 codes are unique identifiers.

    Here is the Python request:

    query = 'area["ISO3166-1"="IS"];nwr[natural=glacier](area);out geom;'
    response = api.get(query)