【问题标题】:Trouble visualize GIS data with Geopandas.plot()使用 Geopandas.plot() 无法可视化 GIS 数据
【发布时间】:2022-11-17 22:54:40
【问题描述】:

我想在 googlecolab 中可视化有关伊朗事故的 GIS 数据,我有纬度、经度和死亡人数信息,但是当我尝试将其作为 Geopaandas 数据框读取时,绘图功能无法正常工作,请就此问题向我提出建议,我有 3720 行和 3 列,可视化结果作为链接附上,在此先感谢您的帮助。

import pandas as pd
import matplotlib.pyplot as plt
import geopandas as gpd
df = pd.read_excel("/content/accidents98.xlsx")
gdf = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df.latitude  , df.longitude))
gdf['death_count']] = gdf[['death_count']].fillna(value=0)
fig, ax = plt.subplots(1, figsize=(20, 20))
ax.axis('off')
ax.set_title('accidents in Iran',
             fontdict={'fontsize': '15', 'fontweight' : '3'})
fig = gdf.plot(column='death_count', cmap='RdYlGn', linewidth=0.5, ax=ax, edgecolor='0.2',legend=True)

输入: input

输出: output

【问题讨论】:

    标签: python google-colaboratory geopandas


    【解决方案1】:

    你有points_from_xy(df.latitude , df.longitude)points_from_xy 期望 (x, y) 而不是 (y, x)。您需要将纬度/经度顺序切换为经度、纬度

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      相关资源
      最近更新 更多