大家應(yīng)該都在學(xué)生時(shí)代使用過12306購買過學(xué)生票,不知道有沒有注意到12306的全國高校數(shù)據(jù);
經(jīng)過分析是一個(gè)json 文件 ,URL和數(shù)據(jù)詳情如下。
https://kyfw.12306.cn/otn/userCommon/schoolNames

12306高校數(shù)據(jù)
那么作為一個(gè)愛折騰的GISer,我們能做點(diǎn)什么呢?
下面我們就通過高德的地址解析API來分析出各個(gè)高校的地址,進(jìn)而做一張全國高校的分布圖。
本次采用Python來調(diào)用API解析,下面給出Python代碼
#-*- coding:utf-8 -*-
import requests
import json
from requests import exceptions
def geocode(address):
parameters = {'address': address, 's': 'rsv3', 'key': '這里填寫你的高德地圖token'}
base = 'http://restapi.amap.com/v3/geocode/geo'
response = requests.get(base, parameters)
answer = response.json()
if any(answer['geocodes']):
if any(answer['geocodes'][0]['city']):
if any(answer['geocodes'][0]['district']):
return answer['geocodes'][0]['location'] + "," + answer['geocodes'][0]['province'] + "," + answer['geocodes'][0]['city'] + "," + answer['geocodes'][0]['district']
else:
return answer['geocodes'][0]['location'] + "," + answer['geocodes'][0]['province'] + "," + ","
else:
return answer['geocodes'][0]['location'] + "," + answer['geocodes'][0]['province'] + "," + ","
else:
return ","
url = "https://kyfw.12306.cn/otn/userCommon/schoolNames"
response = requests.get(url)
json_str = response.content.decode()
ret1 = json.loads(json_str)
for data in ret1["data"]:
lonlat = geocode(data["chineseName"])
# print(lonlat)
school = data["chineseName"]+","+lonlat+","+data["simplePin"]+","+data["stationTelecode"]+"\r\n"
print(school)
with open("12306withlonlat.csv", "a+", encoding="utf-8") as f:
f.write(school)
解析完成之后,我們會(huì)得到這樣的包含有地址和經(jīng)緯度的csv文件,獲取到的csv文件中還是有一部分不能獲取到位置信息的,一般都是一些研究所和某些涉密的部門,需要我們對數(shù)據(jù)進(jìn)一步的篩選和處理。

地址解析結(jié)果
然后我們使用SuperMap iDesktop的屬性轉(zhuǎn)點(diǎn)講這些數(shù)據(jù)轉(zhuǎn)換為點(diǎn)數(shù)據(jù),

image.png
轉(zhuǎn)換教程地址 : http://v.youku.com/v_show/id_XMTQxNjk0ODEzMg==.html?spm=a2hzp.8253869.0.0
底圖為摩卡托天地圖

點(diǎn)位分布

熱力圖

四邊形網(wǎng)格

六邊形網(wǎng)格

換一個(gè)暗色的底圖,是不是立馬高大上了?
分析的結(jié)果清晰的顯示,大西北的教育還是比較欠缺?。。?!