酷代码 AI
菜单
服务商

用 PyCharm 代码:按权属性质从地类图斑与栅格影像中精准提取影像

```python import rasterio import geopandas as gpd # 读取地类图斑图层 dltb = gpd.read_file('data3/dltb.shp') # 读取栅格影像图层 image = rasterio.open('data3/image.tif') # 根据权属性质字段的不同,分别提取31(组集体)、32(村集体)、33(镇集体)的影像 group_image = image.read(1)[dltb[dltb['qsdw'] == '31'].geometry.values] village_image = image.read(1)[dltb[dltb['qsdw'] == '32'].geometry.values] town_image = image.read(1)[dltb[dltb['qsdw'] == '33'].geometry.values] # 保存提取出的影像 with rasterio.open('data3/group_image.tif', 'w', image.profile) as dst: dst.write(group_image, 1) with rasterio.open('data3/village_image.tif', 'w', image.profile) as dst: dst.write(village_image, 1) with rasterio.open('data3/town_image.tif', 'w', image.profile) as dst: dst.write(town_image, 1) ``` ######[AI写代码神器 | 545点数解答 | 2024-06-30 05:32:46]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]