0

我正在尝试使用 Python 的 Altair 包创建一个州的地理地图。然后,我将在其纬度和经度指定的位置绘制表示某个事件的点。我在这里关注 Altair 的示例库。TopoJSON 文件位于 GitHub 存储库deldersveld/topojson中。但是,我无法用它来绘制密歇根州的地图。该文件是否缺少某些内容?谁能帮助我?

环境:

  • 视窗 10
  • 蟒蛇 3
  • jupyter实验室1.0.0a3
  • 牵牛星 3.0
4

1 回答 1

3

你可以这样做:

import altair as alt

url = "https://raw.githubusercontent.com/deldersveld/topojson/master/countries/us-states/MI-26-michigan-counties.json"

source = alt.topo_feature(url, "cb_2015_michigan_county_20m")

alt.Chart(source).mark_geoshape().encode(
    tooltip='properties.NAME:N'
)

在此处输入图像描述

关键是查看 TopoJSON 文件的"objects""properties"条目,以找出用于特征和编码的内容。

于 2019-05-31T14:26:28.653 回答