问题
Iam writing a simple code and would like to export the content of the GEODATAFRAME to excel.
Please advise what is the simplest way to achieve that.
The code is as follows:
import geopandas as gpd
import pandas as pd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
import matplotlib.pyplot as plt
plt.show()
print(world)
I have tried the following code without success:
xlpath='C:/'
df=pd.DataFrame(eval(world))
export_excel = df.to_excel(xlpath)
This is the GEODATAFRAME(table) that i want to export to excel.
回答1:
It works the same as a pandas dataframe - you can just Google how to do that.
In your case
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
xlpath='C:/'
world.to_excel(xlpath) # do not use here export_excel=df.to_excel...
来源:https://stackoverflow.com/questions/58478193/how-to-export-a-geopandas-dataframe-to-excel