我最近写了一篇有关使用basemap制作地图的博客文章,其中我使用shapefile在英格兰和威尔士的邮政编码区域进行绘制和着色。这可能会有帮助。http://www.jamalmoir.com/2016/06/creating-
map-visualisations-in-python.html
基本上,您可以使用shapefile创建一个PatchCollection,然后为PatchCollection着色。然后将其添加到地图中,鲍勃是您的叔叔。
m.readshapefile('data/uk_postpre_bounds/Areas', 'areas')df_poly = pd.Dataframe({ 'shapes': [Polygon(np.array(shape), True) for shape in m.areas], 'area': [area['name'] for area in m.areas_info] })df_poly = df_poly.merge(new_areas, on='area', how='left')cmap = plt.get_cmap('Oranges') pc = PatchCollection(df_poly.shapes, zorder=2)norm = Normalize()pc.set_facecolor(cmap(norm(df_poly['count'].fillna(0).values)))ax.add_collection(pc)
在此示例中,我使用新房子的数量为每个区域着色,但是您可以做自己喜欢的事情。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)