Geopandas初体验

最近由于项目,学习了Geopandas,主要用于对GIS数据的读取与处理。

import geopandas
import matplotlib.pyplot as plt
import numpy as np

path1="f:\\shapefile\\gis_osm_buildings_a_free_1.shp"
path2="C:\\Users\\Administrator\\Desktop\\GIS\\tx\\000067a4-8fde-4b03-8b34-9be9b3d09438\\converted.shp\\lines.shp"
#gdf1=geopandas.read_file(path1)                            #读取shapefile文件,可设置bbox选定区域
gdf2=geopandas.read_file(path2)

def str2dic(s):
    if s is not None:
        s='{'+s.replace('=>',':')+'}'
        return eval(s)
    else:
        return dict()

print(gdf2.columns)
g=gdf2['other_tags']
for i in range(len(g)):
    print(str2dic(g[i]))

print(gdf2['name'])                                               #输出name列

gdf=gdf2.drop(axis=1,columns='man_made',inplace=False)            #删除某列

gdf.insert(0,'new col',np.arange(456))                            #插入某列

print(gdf.columns)                                                #输出所有列名

gdf.plot()                                                        #画图
plt.show()

猜你喜欢

转载自blog.csdn.net/qq_40268672/article/details/107239950
今日推荐