I am trying to use the ExtractByMask tool on a multidimension raster dataset by using the ForEach tool,
The raster data is gridded historical climate data of monthly maximum air temperature.
The mask data is a vector data set of vegetation communities,
Here is the code
import arcpy
climate_file_historic_monthly_1950_54 = r"D:\temp\climate_projections\macav2metdata_tasmax_GFDL-ESM2M_r1i1p1_historical_1950_1954_CONUS_monthly.nc"
max_temp_hist_monthly_raster = arcpy.Raster(climate_file_historic_monthly_1950_54,True)
eru_data_file = r"D:\temp\RegionalSeralStateDeparture.gdb\Ecological_Response_Unit"
arcpy.management.MakeFeatureLayer(eru_data_file,'eru_data',"R3ERUCODE = 'MCD'")
arcpy.CheckOutExtension('Spatial')
arcpy.sa.Foreach(max_temp_hist_monthly_raster,'ExtractByMask',{'in_mask_data':'eru_data'})
:
The error returned is
RuntimeError Traceback (most recent call last)
In [70]:
Line 1: arcpy.sa.Foreach(max_temp_hist_monthly_raster,'ExtractByMask',{'in_mask_data':'eru_data'})
File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\ia\_ia.py, in Foreach:
Line 114: return arcgisscripting._ia.Foreach(in_raster=in_raster,
RuntimeError: Invalid Raster Function: 'ExtractByMask' The documentation on using the ForEach tool is a bit scanty. Using the ExtractByMask tool from the analysis tools returns a single band raster. I am looking for the extracted data by each slice.