Geopandas GeoDataFame的Choropleth地图 [英] Choropleth map from Geopandas GeoDataFame

查看:87
本文介绍了Geopandas GeoDataFame的Choropleth地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Geopandas GeoDataFrame中的多边形制作一个Choropleth地图.我想通过GeoDataFrame列之一中的值的分位数来符号化多边形.我正在尝试找出不同的选项,并找出最适合我的需求.任何对此的建议将不胜感激.

I'm trying to make a choropleth map from polygons in a Geopandas GeoDataFrame. I want to symbolize the polygons by quantiles of a value in one of the GeoDataFrame columns. I'm trying to figure out different options and see what best fits my needs. Any advice on this would be greatly appreciated.

看来Geopandas确实已经具备执行此操作的能力:

It appears that Geopandas does have some ability to do this already: http://nbviewer.ipython.org/github/geopandas/geopandas/blob/master/examples/choropleths.ipynb

tracts.plot(column='CRIME', scheme='QUANTILES', k=3, colormap='OrRd')

这很有效,尽管我找不到太多的文档.我希望能够添加一个显示分位数截止值的图例,但看来Geopandas图当前仅允许基于分类数据的图例.有人为此有工作吗?

This works, although I can't find much documentation. I'd like to be able to add a legend that shows the quantile cut-off values, but it appears that the Geopandas plot currently only allows for legends based of categorical data. Does anyone have a work around for this?

此外,我希望能够调整多边形轮廓的宽度.这可能吗?

Additionally, I'd like to be able to adjust the polygon outline width. Is this possible?

作为替代方案,我一直在使用matplotlib中的面片.这似乎涉及更多,但似乎确实提供了更多的自定义选项.如果有必要沿着这条路走以建立图例,我可以跟进另一个问题,并包括到目前为止的代码.

As an alternative option I've been playing around with is using polygon patches in matplotlib. This appears much more involved but does seem to offer more options to customize. If necessary to go down this route in order to build a legend I can follow-up with another question and will include my code so far.

感谢您的帮助.

推荐答案

以下补丁已集成在geopandas中,因此您现在可以执行以下操作:

The below patch is integrated in geopandas, so you can do now just:

tracts.plot(column='CRIME', scheme='QUANTILES', k=3, colormap='OrRd', legend=True)


我对geopandas的plot_dataframe功能做了一个小补丁,以在使用PySAL方案时启用图例.您可以在这里找到它: http://nbviewer.ipython.org/gist/jorisvandenbossche/d4e6efedfa1e4e91ab65(该调整仅在if scheme is not None:之后的几行中).


I made a small patch to the plot_dataframe function of geopandas to enable a legend when using a PySAL scheme. You can find it here: http://nbviewer.ipython.org/gist/jorisvandenbossche/d4e6efedfa1e4e91ab65 (the adjustment is only in the few lines after if scheme is not None:).

这使您可以执行以下操作:

This lets you do the following:

ax = plot_dataframe(tracts, column='CRIME', scheme='QUANTILES', k=3, colormap='OrRd', legend=True)

得到这样的数字:

这篇关于Geopandas GeoDataFame的Choropleth地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆