用 Matplotlib 绘制地图?
如果有人不知道: 地图 是一种地图,其中某些国家/地区 -依赖的数值属性会缩放相应的区域,以便该属性的密度(接近)恒定。一个示例是
来自 worldmapper.org。在此示例中,国家根据其人口进行缩放,从而导致人口密度接近恒定。
不用说,这真的很酷。有谁知道用于绘制此类地图的基于 Matplotlib 的库? worldmapper.org 使用的方法在 (1) 中进行了描述,所以如果还没有人实现这一点,我会感到惊讶...
我也有兴趣了解其他制图库,即使它们不是为 Matplotlib 制作的。
(1) 迈克尔·T·加斯特纳 (Michael T. Gastner) 和 MEJ 纽曼 (MEJ Newman), 用于生成密度均衡图的基于扩散的方法, 过程。纳特。阿卡德。科学。美国,101,7499-7504 (2004)。可在 arXiv 获取。
In case somebody doesn't know: A cartogram is a type of map where some country/region-dependent numeric property scales the respective regions so that that property's density is (close to) constant. An example is
from worldmapper.org. In this example, countries are scaled according to their population, resulting in near-constant population density.
Needless to say, this is really cool. Does anyone know of a Matplotlib-based library for drawing such maps? The method used at worldmapper.org is described in (1), so it would surprise me if no one has implemented this yet...
I'm also interested in hearing about other cartogram libraries, even if they're not made for Matplotlib.
(1) Michael T. Gastner and M. E. J. Newman,
Diffusion-based method for producing density-equalizing maps,
Proc. Nat. Acad. Sci. USA, 101, 7499-7504 (2004). Available at arXiv.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
有this,尽管它是基于不同的算法(尽管它位于 ESRI站点,它不需要 ArcGIS)。当然,一旦你有了地图,你就可以在 matplotlib 中绘制它。
There's this, though it's based and a different algorithm (and though it's on the ESRI site, it doesn't require ArcGIS). Of course, once you have the cartogram you can plot it in matplotlib.
这里是一个使用 D3 制作地图的 Javascript 插件。如果您不太关心区域大小是否准确,那么这是一个很好、简单的解决方案。如果准确性很重要,还有其他可用选项可以让您更自由地使用算法参数以获得更准确的结果。
以下是我所知道的两个很棒的独立程序:
Scapetoad 非常容易使用。只需给它一个 shapefile,告诉它使用哪个属性进行缩放,并设置一些精度参数即可。如果有任何疑问,这篇文章描述了该过程。
Carto3F 更复杂,并且具有更高的准确性,尽管弄清楚起来有点棘手 - 有很多参数设置,但没有太多文档解释它们。
还有一个用 Python 编写的 QGIS 地图插件。虽然我还没能让它发挥作用,所以不能对此发表评论。
Here is a Javascript plugin to make cartograms using D3. It is a good, simple solution if you are not too concerned about the regions being sized accurately. If accuracy is important, there are other options available that give you more freedom to play with the algorithm's parameters to get to a more accurate result.
Here are two great standalone programs I know of:
Scapetoad is very easy to use. Just give it a shapefile, tell it which attribute to use for the scaling, and set a few accuracy parameters. If there is any doubt, this post describes the process.
Carto3F is more complex and allows for greater accuracy, though it is a bit trickier to figure out - lots of parameter settings without much documentation explaining them.
There is also a QGIS cartogram plugin, written in Python. Though I have not been able to get it to work, so cannot comment on that one.
geoplot.cartogram 函数
Geoplot:地理空间数据可视化——geoplot 0.2.0
说它是一个高级Python地理空间绘图库,以及 cartopy 和 matplotlib 的扩展。
The geoplot.cartogram function in
Geoplot: geospatial data visualization — geoplot 0.2.0
says it is a high-level Python geospatial plotting library, and an extension to cartopy and matplotlib.
简而言之,不。但是 Newman 在他的网站上在他的网站上实现了他和 Gastner 的方法。安装它很简单,并且可以通过命令行运行。这是使用对我有用的该软件的工作流程示例。
cart
程序。主页上有很好的说明。
In short, no. But Newman has an excellent little implementation of his and Gastner's method on his website. Installing it is easy and it works from the command line. Here's an example of a workflow using this software that worked for me.
cart
program with your density matrix as input from the command line or from as subprocess in Python.interp
program and into a new shapefile to get the transformed map.There are nice instructions on the main page.
如果您使用 geopandas,请尝试这个库,它速度很快并且不需要太多自定义。 https://github.com/mthh/cartogram_geopandas
Try this library if you are using geopandas, it is quick and doesnt require much customization. https://github.com/mthh/cartogram_geopandas