用R语言读取经纬度的一个要领
依赖于google的一个处事,天天只能读取2500个,每个地点也没有google earth较准确,但可以作为参考。
require(RCurl)
require(XML)
require(rjson)
x1 = getURI(‘http://maps.googleapis.com/maps/api/geocode/json?address=Jiutian,+Taihu,+anhui+china&sensor=false’)
x2
=
getURI(‘http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false’)
y1 = fromJSON(x1)
y2 = xmlParse(x2)
y1$results[[1]]$geometry$location$lat
y1$results[[1]]$geometry$location$lng
xmlValue(getNodeSet(doc = y2, path = “//geometry//location//lat”)[[1]])
xmlValue(getNodeSet(doc = y2, path = “//geometry//location//lng”)[[1]])