在用Basemap创建了一些地图之后,我变得热情起来。我想集成shapefile信息,比如一个多边形,但是有一些问题。我在这里下载了巴伐利亚乡村的寄宿生:
https://www.arcgis.com/home/item.html?id=b752861d1a08489b9a40337668d4367e
现在我要对一个多边形进行积分,比如说,雷根斯堡。我可以用这段代码获取信息,但是我有一些问题
#!/usr/bin/env python
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import shapefile
map = Basemap(projection='merc',
resolution='l',
area_thresh=0.01,
llcrnrlon=9.497681, llcrnrlat=47.827908,
urcrnrlon=12.683716, urcrnrlat=50.408517)
map.drawcountries(color="gray")
map.fillcontinents(color='#c8dfb0', lake_color='#53BEFD')
map.drawmapboundary(color='black', linewidth=0.5, fill_color='#53BEFD')
sf = shapefile.Reader("BY_Gemeinden/BY_Gemeinden_WM.shp")
shapes = sf.shapes()
records = sf.records()
for record, shape in zip(records, shapes):
if record[3] == "Regensburg":
print(shape.shapeType)
lons, lates = zip(*shape.points)
print(record)
print(lons)
print(lates)
plt.savefig("foo.eps")
输出如下:
^{pr2}$我的问题:
lon[1],lon[1]
是边界的一个点。显然还有很多。在shapeType
?records
中的数字是多少?在非常感谢!!!在
我最近写了一篇关于用Basemap制作地图的博客文章,在这篇文章中,我用形状文件在英格兰和威尔士的邮政编码区域绘制和着色。这可能会有所帮助。http://www.jamalmoir.com/2016/06/creating-map-visualisations-in-python.html
基本上你可以用你的shapefile创建一个PatchCollection,然后给它上色。然后你把它加到你的地图上,鲍勃就是你叔叔。在
在这个例子中,我用新房子的数量来给每个区域上色,但是你可以随心所欲。在
相关问题 更多 >
编程相关推荐