用 Matplotlib 绘制地图?

发布于 2024-10-03 17:11:48 字数 701 浏览 2 评论 0原文

如果有人不知道: 地图 是一种地图,其中某些国家/地区 -依赖的数值属性会缩放相应的区域,以便该属性的密度(接近)恒定。一个示例是

Example cartogram

来自 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

Example cartogram

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

鹿童谣 2024-10-10 17:11:48

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.

姐不稀罕 2024-10-10 17:11:48

这里是一个使用 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.

段念尘 2024-10-10 17:11:48

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.

天赋异禀 2024-10-10 17:11:48

简而言之,不。但是 Newman 在他的网站上在他的网站上实现了他和 Gastner 的方法。安装它很简单,并且可以通过命令行运行。这是使用对我有用的该软件的工作流程示例。

  1. 计算某个区域的密度估计网格,例如在 Python 中。将其存储为数字矩阵。
  2. 使用密度矩阵作为来自命令行或 Python 子进程的输入来运行 cart 程序。
  3. 该程序返回每个网格点的新坐标列表。
  4. 通过 interp 程序将 shapefile 点传输到新的 shapefile 中以获取转换后的地图。

主页上有很好的说明。

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.

  1. Compute a grid of density estimates over some region, e.g. in Python. Store it as a matrix of numbers.
  2. Run the cart program with your density matrix as input from the command line or from as subprocess in Python.
  3. The program returns a list of new coordinates for each grid point.
  4. Pipe your shapefile points through the interp program and into a new shapefile to get the transformed map.

There are nice instructions on the main page.

雨落星ぅ辰 2024-10-10 17:11:48

如果您使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文