Geopandas,将背景地图添加到绘图中

时间:2020-03-26 15:19:14

标签: python geopandas

在运行此程序时出现问题,提示值错误:无法转换原始几何。请先在对象上设置crs。

# data frame loading
df = pd.read_csv('C:/Users/barke/PycharmProjects/UK-COVID-19/data/NHSRcasestable.csv')

# geodataframe
gdf = geopandas.GeoDataFrame(
    df, geometry=geopandas.points_from_xy(df.Longitude, df.Latitude))

# plotting coordinates over a country level map
world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
ax = world[(world.name == "United Kingdom")].plot(color='white', edgecolor='black')

# base map addition
gdf = gdf.to_crs(epsg=27700)
ax = gdf.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
ctx.add_basemap(ax)

0 个答案:

没有答案