サマリー
Creates a raster object that is a subset of the input multidimensional raster based on selected variables and dimension intervals.
説明
Use the Subset function to extract a subgroup of variable data from a multidimensional raster object. You can use the subgroup as an input to additional functions. For example, to calculate the average monthly precipitation values for a multidimensional raster that contains both temperature and precipitation data, you can first use Subset to extract the precipitation variable only as a raster object. Then you can use the Aggregate function to compute the monthly average.
The function creates a raster object that is a subgroup of the input, with dimension and variable information defined by the input parameters.
The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.
構文
Subset (in_raster, {variables}, {dimension_definitions})
パラメーター | 説明 | データ タイプ |
in_raster | The input multidimensional raster dataset. | Raster |
variables [variables,...] | A variable name or a list of variable names to be included in the output raster. If not specified, all variables will be included. | String |
dimension_definitions | The dimension interval used to subset the multidimensional raster. This parameter is passed as a dictionary in which the key:value pairs are described as dimension_name:dimension interval. The key is the name of the dimension along which you wish to subset, and the value is the dimension interval. The dimension interval must use one of the following formats:
| Dictionary |
データ タイプ | 説明 |
Raster | The output subset multidimensional raster. |
コードのサンプル
Extract four subsets from climate multidimensional data and save the final subset.
import arcpy
from arcpy.ia import *
in_raster = Raster('ClimateData_Daily.nc', True)
# Select two variables: precipitation and water temperature
out_subset_raster1 = Subset(in_raster, variables = ['precip', 'water_temp'])
print(out_subset_raster1.variables)
# Filter variables that have the Depth dimension and where depth=0.
# For variables that do not have dimension depth, all slices are selected.
out_subset_raster2 = Subset(in_raster, dimension_definitions = {'depth' : 0})
print(out_subset_raster2.variables)
# Select water temperature data on the 1st of every January
out_subset_raster3 = Subset(in_raster, variables = 'water_temp',
dimension_definitions = {'time':
('1980-01-01T12:00:00', None, 1, 'year')})
print(out_subset_raster3.variables)
# Select water temperature data for the first three months of every year
out_subset_raster4 = Subset(in_raster, variables = 'water_temp',
dimension_definitions = {'time':('1980-01-01T00:00:00',
'1980-03-31T00:00:00', 1, 'year')})
# Select both variables for January in 5 year increments: 1980, 1985, 1990, etc.
out_subset_raster5 = Subset(in_raster, variables = ['precip', 'water_temp']),
dimension_definitions = {'time':
('1980-01-01T00:00:00', '1980-01-31T00:00:00', 5, 'year')})
# Select surface water temperature in January 1980
out_subset_raster6 = Subset(in_raster, variables = 'water_temp',
dimension_definitions = {'time':
('1980-01-01T12:00:00', '1980-01-31T12:00:00'), 'depth': 0})
print(out_subset_raster4.mdinfo)
# Save the water temperature in January 1980
out_subset_raster6.save("c:/output/Jan1980_watertemp.crf")