我正在尝试使用ggmap绘制英国LSOA边界(http://www.ons.gov.uk/ons/guide-method/geography/products/census/spatial/2011/index.html)。
我运行脚本:
import requests
city = 'dublin'
country = 'ireland'
info = requests.get('http://api.openweathermap.org/data/2.5/weather?q='+city +','+ country +'&mode=json')
weather = info.json()['weather']
fh = open('/home/Ricky92d3/city.txt', 'w')
fh.write(str(weather))
fh.close()
fl = open('/home/Ricky92d3/city.txt')
Object = fl.read()
fl.close()
for line in str(Object):
if line.startswith ('['):
new_Object = Object.replace('[', '')
if line.startswith ('{'):
new_Object = Object.replace('{u', '')
print new_Object
该过程需要15分钟,然后在尝试在ggmap上绘制数据时会崩溃。有没有更快的方式来读取形状文件?也许仅通过读取我需要一次映射的设定区域?
例如)给出的区域:
library(rgdal)
system.time(
LSOA<-readOGR("LSOA_2011_EW_BFE_V2.shp", layer="LSOA_2011_EW_BFE_V2") %>%
spTransform(CRS("+proj=longlat + datum=WGS84"))
LSOAtab= fortify(GMSM,region="Lsoa11cd")
)