gdal_merge.py

马赛克一组图像。

简介

gdal_merge.py [-o out_filename] [-of out_format] [-co NAME=VALUE]*
              [-ps pixelsize_x pixelsize_y] [-tap] [-separate] [-q] [-v] [-pct]
              [-ul_lr ulx uly lrx lry] [-init "value [value...]"]
              [-n nodata_value] [-a_nodata output_nodata_value]
              [-ot datatype] [-createonly] input_files

描述

This utility will automatically mosaic a set of images. All the images must be in the same coordinate system and have a matching number of bands, but they may be overlapping, and at different resolutions. In areas of overlap, the last image will be copied over earlier ones. Nodata/transparency values are considered on a band by band level, i.e. a nodata/transparent pixel on one source band will not set a nodata/transparent value on all bands for the target pixel in the resulting raster nor will it overwrite a valid pixel value.

-o <out_filename>

输出文件的名称,如果它不存在,将创建该文件(默认为“out.tif”)。

-of <format>

选择输出格式。从GDAL 2.3开始,如果未指定,则从扩展名猜测格式(以前是GTiff)。使用短格式名称。

-co <NAME=VALUE>

许多格式都有一个或多个可选的创建选项,可用于控制所创建文件的详细信息。例如,GeoTIFF驱动程序支持创建选项来控制压缩,以及是否应该平铺文件。

可用的创建选项因格式驱动程序而异,有些简单格式根本没有创建选项。格式支持的选项列表可以与 --formats 命令行选项,但该格式的文档是有关驱动程序创建选项的最终信息源。见 栅格驱动器 每种格式的法律创建选项的特定格式文档。

-ot <type>

强制输出图像带具有驱动程序支持的特定数据类型,该数据类型可以是以下类型之一: ByteUInt16Int16UInt32Int32Float32Float64CInt16CInt32CFloat32CFloat64 .

-ps <pixelsize_x> <pixelsize_y>

用于输出文件的像素大小。如果未指定,将使用第一个输入文件的分辨率。

-tap

(target aligned pixels) align the coordinates of the extent of the output file to the values of the -tr, such that the aligned extent includes the minimum extent. Alignment means that xmin / resx, ymin / resy, xmax / resx and ymax / resy are integer values.

-ul_lr <ulx> <uly> <lrx> <lry>

输出文件的范围。如果未指定,则将使用所有输入文件的聚合范围。

-v

生成拼接操作的详细输出。

-separate

将每个输入文件放在一个单独的波段中。

-pct

从第一个输入图像中获取一个伪颜色表,并将其用于输出。以这种方式合并伪彩色图像假定所有输入文件使用相同的颜色表。

-n <nodata_value>

忽略与此像素值合并的文件中的像素。

-a_nodata <output_nodata_value>

为输出频带分配指定的nodata值。

-init <"value(s)">

使用这些值预初始化输出图像带区。但是,它在输出文件中没有标记为nodata值。如果只给定一个值,则在所有频带中使用相同的值。

-createonly

将创建输出文件(并可能进行预初始化),但不会将输入图像数据复制到其中。

备注

gdal_merge.py是一个Python脚本,只有在gdal是使用Python支持构建的情况下才能工作。

例子

创建一个所有波段的像素初始化为255的图像。

gdal_merge.py -init 255 -o out.tif in1.tif in2.tif

创建一个RGB图像,在没有数据的情况下以像素显示蓝色。前两个波段将初始化为0,第三个波段将初始化为255。

gdal_merge.py -init "0 0 255" -o out.tif in1.tif in2.tif