我对Python非常陌生,仍在学习Python语言。我正在浏览Plotly库,并试图了解如何使用外部geojson文件在他们网站上提供的一些自定义地图中使用。我无法理解如何使用geojson文件创建包含我端数据的站点地图。
地图中使用的geojson数据如下所示:
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
主地图视觉代码如下所示-
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
dtype={"fips": str})
import plotly.express as px
fig = px.choropleth(df, geojson=counties, locations='fips', color='unemp',
color_continuous_scale="Viridis",
range_color=(0, 12),
scope="usa",
labels={'unemp':'unemployment rate'}
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
我需要帮助来理解如何在上面的代码中使用geojson文件(在我这里提供)
提前谢谢
目前没有回答
相关问题 更多 >
编程相关推荐