酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

读取data1文件夹中的township.shp图层数据 (1)读取name字段中“志远县”图斑的个数 (2)读取area字段(面积),并计算“罗丰县”的面积之和;源代码中文件存放采用相对路径,不允许出现绝对路径

import geopandas as gpd # 读取township.shp文件 file_path = 'data1/township.shp' data = gpd.read_file(file_path) # 读取name字段中“志远县”图斑的个数 count_zhiyuan = len(data[data['name'] == '志远县']) # 读取area字段(面积),并计算“罗丰县”的面积之和 sum_luofeng = data[data['name'] == '罗丰县']['area'].sum() print("志远县图斑个数:", count_zhiyuan) print("罗丰县面积之和:", sum_luofeng) [2024-06-30 04:06:24 | AI写代码神器 | 266点数解答]

相关提问