All Projects → mvexel → Overpass Api Python Wrapper

mvexel / Overpass Api Python Wrapper

Licence: apache-2.0
Python bindings for the OpenStreetMap Overpass API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Overpass Api Python Wrapper

Mapboxstatic.swift
Static map snapshots with overlays in Swift or Objective-C on iOS, macOS, tvOS, and watchOS
Stars: ✭ 162 (-33.88%)
Mutual labels:  openstreetmap
Opentileserver
This script is for building a basic tile server with OpenStreetMap data
Stars: ✭ 190 (-22.45%)
Mutual labels:  openstreetmap
Id
🆔 The easy-to-use OpenStreetMap editor in JavaScript.
Stars: ✭ 2,667 (+988.57%)
Mutual labels:  openstreetmap
Mimirsbrunn
Geocoding and reverse-geocoding (with OSM data)
Stars: ✭ 165 (-32.65%)
Mutual labels:  openstreetmap
Docker Osm
A docker compose project to setup an OSM PostGIS database with automatic updates from OSM periodically
Stars: ✭ 172 (-29.8%)
Mutual labels:  openstreetmap
Atlasr
Atlasr is a truly open-source and free map browser.
Stars: ✭ 196 (-20%)
Mutual labels:  openstreetmap
Libosmscout
Libosmscout is a C++ library for offline map rendering, routing and location lookup based on OpenStreetMap data
Stars: ✭ 159 (-35.1%)
Mutual labels:  openstreetmap
Osmium Tool
Command line tool for working with OpenStreetMap data based on the Osmium library.
Stars: ✭ 236 (-3.67%)
Mutual labels:  openstreetmap
Openrouteservice App
🚙 The open source route planner app with plenty of features.
Stars: ✭ 187 (-23.67%)
Mutual labels:  openstreetmap
Mapping
OpenStreetMap contributions from the data team at Mapbox
Stars: ✭ 213 (-13.06%)
Mutual labels:  openstreetmap
Aphotomanager
Manage local photos on Android: gallery, geotag with photomap, privacy, tags, find, sort, view, copy, send, ... .
Stars: ✭ 164 (-33.06%)
Mutual labels:  openstreetmap
Osmdeepod
OSMDeepOD - OpenStreetMap (OSM) and Machine Learning (Deep Learning) based Object Detection from Aerial Imagery (Formerly also known as "OSM-Crosswalk-Detection").
Stars: ✭ 174 (-28.98%)
Mutual labels:  openstreetmap
Osmdata
R package for downloading OpenStreetMap data
Stars: ✭ 199 (-18.78%)
Mutual labels:  openstreetmap
Anymaps
Easily switch between Google, Baidu and OSM maps
Stars: ✭ 164 (-33.06%)
Mutual labels:  openstreetmap
Kartotherian
Map Tile Server
Stars: ✭ 230 (-6.12%)
Mutual labels:  openstreetmap
Pyosmium
Python bindings for libosmium
Stars: ✭ 158 (-35.51%)
Mutual labels:  openstreetmap
Geomancer
Automated feature engineering for geospatial data
Stars: ✭ 194 (-20.82%)
Mutual labels:  openstreetmap
Go Staticmaps
A go (golang) library and command line tool to render static map images using OpenStreetMap tiles.
Stars: ✭ 246 (+0.41%)
Mutual labels:  openstreetmap
Loolocator
A simple iOS app that fetches the crowd-sourced data from OpenStreetMaps, and shows toilets within walking distance.
Stars: ✭ 234 (-4.49%)
Mutual labels:  openstreetmap
Osm Python Tools
A library to access OpenStreetMap related services
Stars: ✭ 202 (-17.55%)
Mutual labels:  openstreetmap

Overpass API python wrapper

Looking for a maintainer Hi there, I am the original author of this project. I no longer have time to maintain it but it looks like it's still useful. I'd like to talk to someone who thinks they can take this on. Drop me a line at [email protected]. Thanks! Martijn van Exel

Python bindings for the OpenStreetMap Overpass API.

Install it

pip install overpass

Usage

API() constructor

First, create an API object.

import overpass
api = overpass.API()

The API constructor takes several parameters, all optional:

endpoint

The default endpoint is https://overpass-api.de/api/interpreter but you can pass in another instance:

api = overpass.API(endpoint="https://overpass.myserver/interpreter")

timeout

The default timeout is 25 seconds, but you can set it to whatever you want.

api = overpass.API(timeout=600)

debug

Setting this to True will get you debug output.

Getting data from Overpass: get()

Most users will only ever need to use the get() method. There are some convenience query methods for common queries as well, see below.

response = api.get('node["name"="Salt Lake City"]')

response will be a dictionary representing the JSON output you would get from the Overpass API directly.

Note that the Overpass query passed to get() should not contain any out or other meta statements. See verbosity below for how to control the output.

Another example:

>>> print [(
...     feature['properties']['name'],
...     feature['id']) for feature in response["features"]]
[(u'Salt Lake City', 150935219), (u'Salt Lake City', 585370637)]

You can find more examples in the examples/ directory of this repository.

The get() method takes a few parameters, all optional having sensible defaults.

verbosity

You can set the verbosity of the Overpass query out directive using the same keywords Overpass does. In order of increased verbosity: ids, skel, body, tags, meta. As is the case with the Overpass API itself, body is the default.

>>> import overpass
>>> api = overpass.API()
>>> data = api.get('way(42.819,-73.881,42.820,-73.880);(._;>;)', verbosity='geom')
>>> [f for f in data.features  if f.geometry['type'] == "LineString"]

(from a question on GIS Stackexchange)

responseformat

You can set the response type of your query using get()'s responseformat parameter to GeoJSON (geojson, the default), plain JSON (json), CSV (csv), and OSM XML (xml).

response = api.get('node["name"="Salt Lake City"]', responseformat="xml")

build

We will construct a valid Overpass QL query from the parameters you set by default. This means you don't have to include 'meta' statements like [out:json], [timeout:60], [out body], etcetera. You just supply the meat of the query, the part that actually tells Overpass what to query for. If for whatever reason you want to override this and supply a full, valid Overpass QL query, you can set build to False to make the API not do any pre-processing.

date

You can query the data as it was on a given date. You can give either a standard ISO date alone (YYYY-MM-DD) or a full overpass date and time (YYYY-MM-DDTHH:MM:SSZ, i.e. 2020-04-28T00:00:00Z). You can also directly pass a date or datetime object from the datetime library.

Pre-cooked Queries: MapQuery, WayQuery

In addition to just sending your query and parse the result, overpass provides shortcuts for often used map queries. To use them, just pass them like to normal query to the API.

MapQuery

This is a shorthand for a complete ways and relations query in a bounding box (the 'map call'). You just pass the bounding box to the constructor:

MapQuery = overpass.MapQuery(50.746,7.154,50.748,7.157)
response = api.get(MapQuery)

WayQuery

This is shorthand for getting a set of ways and their child nodes that satisfy certain criteria. Pass the criteria as a Overpass QL stub to the constructor:

WayQuery = overpass.WayQuery('[name="Highway 51"]')
response = api.get(WayQuery)

Testing

Using pytest.

py.test

FAQ

I need help or have an idea for a feature

Create a new issue.

Where did the CLI tool go?

The command line tool was deprecated in version 0.4.0.

See also

There are other python modules that do similar things.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].