ジオコーディングした

とっても素敵なジオコーダーが公開されているので、ありがたく使わせてもらった。ネット越しにAPIを叩くより圧倒的に高速。

% pip3 install jageocorder
% jageocoder download-dictionary https://www.info-proto.com/static/jageocoder/latest/v2/jukyo_all_v20.zip
% jageocoder install-dictionary jukyo_all_v20.zip

町域.txtというファイルに住所の一覧を入れておいて、以下でGoogle MapのURLに変換するだけ。

import json
import jageocoder

jageocoder.init()
sv_address = ''

with open('町域.txt', "r") as f:
    for address in f.readlines():
        if sv_address != address:
            results = jageocoder.search(address)
            lng, lat = results['candidates'][0]['x'], results['candidates'][0]['y']
        print("https://maps.google.com/maps?q={lat},{lng}".format(lat=lat, lng=lng))
        sv_address = address
タイトルとURLをコピーしました