【Python】geopandas 读取 shp/geojson 边界文件

1. 读取 shp/geojson 边界文件

import geopandas as gpd

file = 'media/abc.geojson'
gdf = gpd.read_file(file)
# 将 GeoDataFrame 转换为 GeoJSON 字符串
geojson = json.loads(gdf.to_json())
features = geojson['features']

2. 获取 边界文件的网格范围

import geopandas as gpd

file = 'media/abc.geojson'
gdf = gpd.read_file(file)
grid_bounds = gdf.total_bounds
# 返回一个列表, 包含 最小经度, 最小纬度, 最大经度, 最大纬度
res = grid_bounds.tolist()
posted @   是阿杰呀  阅读(821)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)
点击右上角即可分享
微信分享提示