Merge

概要

Creates a raster object by merging a list of rasters spatially or across dimensions.

ディスカッション

Use the Merge function to merge multiple raster datasets spatially, across variables, or across dimensions.

The function creates a raster object from the merged datasets.

If the input rasters are not multidimensional, they will be merged spatially. If the input rasters are multidimensional and contain different variables, the function will return a multidimensional raster object with all the variables. If the input rasters are multidimensional and contain different dimension values, the function will return a multidimensional raster object with all the dimension values.

構文

Merge (rasters, {resolve_overlap})
パラメーター説明データ タイプ
rasters
[rasters,...]

The list of input rasters.

Raster
resolve_overlap

The method used to handle overlapping pixels when merging rasters spatially or dimensionally.

  • FIRSTThe pixel value will be determined by the raster that appears first in the list of rasters. This is the default.
  • LASTThe pixel value will be determined by the raster that appears last in the list of rasters.
  • MINThe pixel value will be determined by the lowest pixel value in the overlapping rasters.
  • MAXThe pixel value will be determined by the highest pixel value in the overlapping rasters.
  • MEANThe pixel value will be determined by the average of the overlapping pixel values.
  • SUMThe pixel value will be determined by the sum of the overlapping pixel values.

(デフォルト値は次のとおりです FIRST)

String
戻り値
データ タイプ説明
Raster

The output merged raster object.

コードのサンプル

Merge example 1

Merges three land cover raster datasets spatially into a single raster.

import arcpy
from arcpy.ia import *


# Set input rasters
in_raster1 = arcpy.Raster("Canada_landcover.tif")
in_raster2 = arcpy.Raster("USA_landcover.tif")
in_raster3 = arcpy.Raster("Mexico_landcover.tif")

# Merge the three rasters
NorthAmericaLC = arcpy.ia.Merge([in_raster1, in_raster2, in_raster3], "FIRST")
NorthAmericaLC.save("NorthAmerica_landcover.tif")
Merge example 2

Merges two multidimensional raster datasets with different variables into a single multidimensional raster with two variables.

import arcpy
from arcpy.ia import *


# Set input multidimensional rasters
# multidim_1 contains a precipitation variable, measured daily in 2018
# multidim_2 contains a temperature variable, measured daily in 2018
multidim_1 = arcpy.Raster("prcp_daily_2018.nc", True)
multidim_2 = arcpy.Raster("temp_daily_2018.nc", True)

# Merge the two multidimensional rasters
multidim_precip_temp = arcpy.ia.Merge([multidim_1, multidim_2])

# The result contains both daily variables for the year 2018
multidim_precip_temp.save("prcp_and_temp_2018.crf")
Merge example 3

Merges two multidimensional raster datasets with different dimension values into a single multidimensional raster with two years of data.

import arcpy
from arcpy.ia import *


# Set input multidimensional rasters
# multidim_1 contains a precipitation variable, measured daily in 2017
# multidim_2 contains a temperature variable, measured daily in 2018
multidim_1 = arcpy.Raster("precip_daily_2017.nc", True)
multidim_2 = arcpy.Raster("precip_daily_2018.nc", True)

# Merge the two multidimensional rasters
multidim_precip_17_18 = arcpy.ia.Merge([multidim_1, multidim_2])

# The result contains precipitation variables for the years 2017 and 2018
multidim_precip_17_18.save("prcp_2017_and_2018.crf")