LoginSignup
0
2

More than 5 years have passed since last update.

地図にプロットしたい.1

Last updated at Posted at 2018-11-24

中年無能SEのイヤイヤお仕事勉強メモです。
基本的に自分でイチからコード書くこと、英語サイトを調べること極力避けて通ります。

目的

  • 地図上に緯度経度情報をプロットしたい。

参照URL

経緯度データを地図にプロット
https://ikatakos.com/pot/programming/python/packages/basemap

LearnOSM はじめてからのOpenStreetMapガイド
https://learnosm.org/ja/

OpenStreetMapで独自レンダリングをしよう
https://qiita.com/nyampire/items/13ed805ac3ccaff3baf9

とりあえずコピペ

ひとまず最もシンプルなコードで地図ダウンロード可否を確認。

youkidearitai/kasukabe-to-shin-koshigaya.py
https://gist.github.com/youkidearitai/c991ee95b53cdb544d344e2793f732b7

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-f8b15dc7b1db> in <module>()
----> 1 img = get_osm_img(35.99, 139.79, 36.0, 139.80, scale=400, img_format='png')
      2 img.save('kasukabe-to-shin-koshigaya.png')

<ipython-input-3-6b19f4946fa9> in get_osm_img(minlat, minlon, maxlat, maxlon, scale, img_format)
     26     }
     27     response = requests.post(url, payload)
---> 28     return Image.open(BytesIO(response.content))

/anaconda/lib/python3.6/site-packages/PIL/Image.py in open(fp, mode)
   2450         fp.close()
   2451     raise IOError("cannot identify image file %r"
-> 2452                   % (filename if filename else fp))
   2453 
   2454 #

OSError: cannot identify image file <_io.BytesIO object at 0x115144938>

たぶん地図ダウンロードできていない。
ダウンロードできないと言っているひとはいくつかいるが解決法が見つからない。

ダウンロードURLの宛先変更を検討。

url = 'http://www.openstreetmap.org/export/finish'

面倒なんでいったん凍結

こっちをコピペ

Pythonによるデータ可視化ライブラリ「folium」がとても使いやすい
https://qiita.com/momota10/items/3b878f01d489a32e40c3

これでいけそう。
長くなったのでfolium活用ベースで書き直します。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2