YOLP: Extract latitude and longitude with Yahoo! Geocoder API.

Extract only the latitude and longitude information of any address with the Yahoo! Geocoder API.

geo.py



#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import json
import sys, codecs
 
def get_Coordinates(location_name):
    payload = {
    	"appid": "******************************", 
    	"output":"json"
    		}
    payload["query"] = location_name
    url = "http://geo.search.olp.yahooapis.jp/OpenLocalPlatform/V1/geoCoder"
    r = requests.get(url, params=payload)
    
    res = r.json()
    
    for i in res["Feature"]:
    	print i["Geometry"]["Coordinates"]
    	

    
if __name__ == "__main__":
	get_Coordinates(u"4-2-8 Shibakoen, Minato-ku, Tokyo")

Select the data returned by json

    for i in res["Feature"]:
    	print i["Geometry"]["Coordinates"]

It is specified by. For example, if you want to read the data contained in ["Feature"]

    for i in res["Feature"]:
    	print i["Geometry"]["Coordinates"]
    	print i["Property"]["Address"]

You can add something like this. Don't forget the Yahoo copyright notation if you use it somewhere.

Recommended Posts

YOLP: Extract latitude and longitude with Yahoo! Geocoder API.
YOLP Get map information XML file with Yahoo! Static Map API
Operate Jupyter with REST API to extract and save Python code
Try converting latitude / longitude and world coordinates to each other with python
[Rails] Google Maps API Description when latitude and longitude cannot be saved
Visualize latitude / longitude coordinate information with kepler.gl
Extract sudden buzzwords with twitter streaming API
Get the address from latitude and longitude
[Rails] How to calculate latitude and longitude with high accuracy using Geocoding API and display it on Google Map
Distance calculation between two latitude and longitude points with python (using spherical trigonometry)
Collect store latitude / longitude information with scrapy + splash ①
Visualize latitude / longitude coordinate information with kepler.gl
Collect anime song lyrics with Scrapy
Latitude / longitude coordinates ↔ UTM coordinate conversion with python
Get latitude / longitude distance in meters with QGIS
Restart with Scrapy
Get nearby latitude / longitude points with Python's geoindex library
YOLP: Extract latitude and longitude with Yahoo! Geocoder API.
Display Google Maps API with Rails and pin display
Latitude / longitude coordinates ↔ UTM coordinate conversion with python
Get latitude / longitude distance in meters with QGIS
Get Gmail subject and body with Python and Gmail API
Download Geographical Survey tiles from latitude and longitude
Collect store latitude / longitude information with scrapy + splash ①