Last active
December 29, 2016 18:40
-
-
Save youkidearitai/c991ee95b53cdb544d344e2793f732b7 to your computer and use it in GitHub Desktop.
Python plot OpenstreetMap (shin-koshigaya station to kasukabe station (from Tobu Skytree Line)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from io import BytesIO | |
from PIL import Image | |
""" | |
ひとまず地図を表示させるプログラム | |
respect from: http://qiita.com/duonys/items/c941bc2818abe5cc1da7 | |
問題あったら消しますー | |
""" | |
def get_osm_img(minlat, minlon, maxlat, maxlon, scale=60000, img_format='png'): | |
""" | |
OpenstreetMapから取得する | |
最小の緯度・軽度から最大の緯度・軽度を取得する | |
四角く取るという意味なので、地図を作るときには気をつけよう | |
""" | |
url = 'http://www.openstreetmap.org/export/finish' | |
payload = { | |
'mapnik_format': img_format, | |
'mapnik_scale': scale, | |
'minlon': minlon, | |
'minlat': minlat, | |
'maxlon': maxlon, | |
'maxlat': maxlat, | |
'format': 'mapnik' | |
} | |
response = requests.post(url, payload) | |
return Image.open(BytesIO(response.content)) | |
img = get_osm_img(35.87, 139.74, 36.0, 139.80, scale=40000, img_format='png') | |
img.save('kasukabe-to-shin-koshigaya.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment