{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Try-out automatic downloads of OSM data via turbo-overpass API:\n", "http://wiki.openstreetmap.org/wiki/Overpass_API#Python_API\n", "\n", "\n", "a python wrapper is provided by Martijn van Exel via github\n", "https://github.com/mvexel/overpass-api-python-wrapper\n", "\n", "install via pip (not available on conda repos)\n", "\"pip install overpass\"" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[{\"geometry\": {\"coordinates\": [4.35839, 52.0114017], \"type\": \"Point\"}, \"id\": 274247451, \"properties\": {\"is_in\": \"NL\", \"is_in:continent\": \"Europe\", \"is_in:country\": \"The Netherlands\", \"is_in:country_code\": \"NL\", \"is_in:province\": \"South Holland\", \"name\": \"Delft\", \"name:carnaval\": \"Kabbelgat\", \"name:el\": \"\\u039d\\u03c4\\u03b5\\u03bb\\u03c6\\u03c4\", \"name:fa\": \"\\u062f\\u0644\\u0641\\u062a\", \"name:he\": \"\\u05d3\\u05dc\\u05e4\\u05d8\", \"name:ja\": \"\\u30c7\\u30eb\\u30d5\\u30c8\", \"name:ko\": \"\\ub378\\ud504\\ud2b8\", \"name:la\": \"Delphi\", \"name:nds\": \"Delft\", \"name:ru\": \"\\u0414\\u0435\\u043b\\u0444\\u0442\", \"name:sr\": \"\\u0414\\u0435\\u043b\\u0444\\u0442\", \"name:zh\": \"\\u4ee3\\u5c14\\u592b\\u7279\", \"place\": \"city\", \"population\": \"101022\", \"website\": \"http://www.delft.nl\", \"wikipedia\": \"nl:Delft\"}, \"type\": \"Feature\"}]\n" ] } ], "source": [ "import overpass\n", "api = overpass.API()\n", "\n", "# get city with name Delft\n", "response = api.Get('node[\"place\"=\"city\"][\"name\"=\"Delft\"]')\n", "\n", "# response in geojson\n", "from pprint import pprint\n", "pprint(response['features'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "response typically in geojson format. This can be visualized using folium " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "