Zusammenfassung
Creates a raster object by merging a list of rasters spatially or across dimensions.
Diskussion
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.
Syntax
Merge (rasters, {resolve_overlap})
Parameter | Erläuterung | Datentyp |
rasters [rasters,...] | The list of input rasters. | Raster |
resolve_overlap | The method used to handle overlapping pixels when merging rasters spatially or dimensionally.
(Der Standardwert ist FIRST) | String |
Datentyp | Erläuterung |
Raster | The output merged raster object. |
Codebeispiel
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")
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")
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")