geopandas获取shp的四个角点的经纬度
要获取shapefile的四个角点的经纬度,你可以使用geopandas库中的方法来读取shapefile,并使用GeoDataFrame的bounds属性来获取shapefile的边界框。边界框是一个包含最小纬度、最小经度、最大纬度和最大经度的元组。下面是一个示例代码:
import geopandas as gpd
# 读取shapefile
gdf = gpd.read_file('path_to_shapefile.shp')
# 获取边界框
min_lon, min_lat, max_lon, max_lat = gdf.bounds.values[0]
print("最小经度:", min_lon)
print("最小纬度:", min_lat)
print("最大经度:", max_lon)
print("最大纬度:", max_lat)
请确保将'path_to_shapefile.shp'替换为实际的shapefile文件路径。这段代码将打印出shapefile的四个角点的经纬度。
原文地址: http://www.cveoy.top/t/topic/iXpF 著作权归作者所有。请勿转载和采集!