写段利用python在arcgis中批量裁剪影像的代码
时间: 2023-10-03 21:07:21 浏览: 105
好的,以下是可以回答的Python代码:
```
import arcpy
# 设置工作空间路径和待裁剪数据路径
workspace = "C:/data"
input_data_path = "C:/data/input_data.shp"
# 待裁剪的影像数据路径
raster_path = "C:/data/raster.tif"
# 设置输出文件夹路径
output_folder_path = "C:/data/output"
# 获取待裁剪数据和影像数据的描述符对象
input_data_desc = arcpy.Describe(input_data_path)
raster_desc = arcpy.Describe(raster_path)
# 获取待裁剪数据图层和影像数据集的名称
input_data_name = input_data_desc.name
raster_name = raster_desc.name
# 设置裁剪输出路径和输出像素类型
output_raster_path = output_folder_path + "/" + raster_name + "_clipped.tif"
pixel_type = raster_desc.pixelType
# 执行批量裁剪
arcpy.Clip_management(raster_path, "#", output_raster_path, input_data_path, "#", "ClippingGeometry", "NO_MAINTAIN_EXTENT", "NONE", "NONE", "NONE", "NONE")
# 打印成功提示信息
print("影像裁剪成功!输出路径为:" + output_raster_path)
```
希望这个代码可以帮助到您,如果您有其他问题,请继续提问。
阅读全文