简体   繁体   English

使用 Geopandas.plot() 无法可视化 GIS 数据

[英]Trouble visualize GIS data with Geopandas.plot()

I want to visualize the GIS data about Iran accidents in googlecolab, I have latitude, longitude, and death_count information but when I try to read it as Geopaandas data frame the plot function is not working correctly, May you please advise me on this issue, I have 3720 rows and 3 columns, and the result of visualization is attached as a link, thanks in advance for your help.我想在 googlecolab 中可视化有关伊朗事故的 GIS 数据,我有纬度、经度和死亡人数信息,但是当我尝试将其作为 Geopaandas 数据框读取时,plot function 无法正常工作,请就此问题向我提出建议,我有 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.longitude)و df.latitude))
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)

the input:输入:输入

the output: output:输出

You have points_from_xy(df.latitude, df.longitude) .你有points_from_xy(df.latitude, df.longitude) points_from_xy expects (x, y) not (y, x) . points_from_xy期望(x, y)而不是(y, x) You need to switch the lat/lon order to lon, lat您需要将纬度/经度顺序切换为经度、纬度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM