arcpy 批量镶嵌合并一个文件夹下的栅格影像

对“镶嵌至新栅格”工具做一个小小的补充,使其能够直接对一个文件夹下的栅格进行镶嵌。

# coding=utf-8
import arcpy
from arcpy import env
rasterFolder=arcpy.GetParameterAsText(0)
newRasterName=arcpy.GetParameterAsText(1)
coordinateSystem=arcpy.GetParameterAsText(2)
pixelType=arcpy.GetParameterAsText(3)
cellSize=arcpy.GetParameterAsText(4)
numberOfBands=arcpy.GetParameterAsText(5)
mosaicMethod=arcpy.GetParameterAsText(6)
mosaicColormapMode=arcpy.GetParameterAsText(7)

env.workspace=rasterFolder
rsts=arcpy.ListRasters()
arcpy.MosaicToNewRaster_management(
    input_rasters=";".join(rsts),
    output_location=rasterFolder,
    raster_dataset_name_with_extension=newRasterName,
    coordinate_system_for_the_raster=coordinateSystem,
    pixel_type=pixelType,
    cellsize=cellSize,
    number_of_bands=3,
    mosaic_method=mosaicMethod,
    mosaic_colormap_mode=mosaicColormapMode
    )

 

posted @ 2020-02-16 15:13  yzhyingcool  阅读(2767)  评论(1编辑  收藏  举报