Synthèse
Calculates the gradient along x, y, x,y, or a given dimension.
Discussion
The Gradient function works on a single-band input. If the input is multiband, the first band will be used. Use the ExtractBand function to specify the required band.
For multidimensional input that contains multiple variables, all variables will be processed. If a variable does not contain the specified gradient_dimension parameter, it will be ignored. Use the Multidimensional Filter function to select the required variables.
The Multidimensional Filter function can also be used to define the dimension range for which the function is applied.
The following table lists the equations for the various gradient calculations:
Gradient type | Equation |
---|---|
Gradient X |
|
Gradient Y |
|
Gradient for a dimension |
|
Syntaxe
Gradient (raster, {gradient_dimension}, {denominator_unit})
Paramètre | Explication | Type de données |
raster [raster,...] | The input raster or list of rasters. | Raster |
gradient_dimension | The available dimensions for which the gradient will be calculated. For nonmultidimensional input, available dimension options are X, Y, and XY. For multidimensional input, available dimension options are X, Y, XY, and all dimensions available in the data, including time (StdTime). If there are two or more dimensions, the gradient will be calculated on the gradient dimension for all slices in the available dimensions. The XY option outputs a 2-band raster in which band 1 represents the gradient along the x-dimension, and band 2 represents the gradient along the y-dimension. (La valeur par défaut est X) | String |
denominator_unit | The unit of the gradient denominator. The unit depends on the gradient_dimension argument value. The following options are available for X, Y, and XY:
The following options are available for StdTime:
The following options are available for dimensions other than time dimensions:
(La valeur par défaut est DEFAULT) | String |
Type de données | Explication |
Raster | The output raster. |
Exemple de code
Calculate the gradient along the x and y dimensions of a Landsat image.
# Import system modules
import arcpy
from arcpy.ia import *
arcpy.ia.Gradient (raster, gradient_dimension, denominator_unit)
# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")
# Set local variables
input_raster = in_multidimensional_raster = "C:/data/landsat.crf"
gradient_dimension = “XY”
denominator_unit = “Cellsize”
# Apply Gradient function
gradient_raster = arcpy.ia.Gradient (raster, gradient_dimension, denominator_unit)
# Save the output
gradient _raster.save("C:/output/landsat_xy_gradient.crf")
This example calculates the gradient along StdTime of an NDVI time series.
# Import system modules
import arcpy
from arcpy.ia import *
arcpy.ia.Gradient (raster, gradient_dimension, denominator_unit)
# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")
# Set local variables
input_raster = in_multidimensional_raster = "C:/data/ndvi_time_series.crf"
gradient_dimension = “StdTime”
denominator_unit = “Per Year”
# Apply Gradient function
gradient_raster = arcpy.ia.Gradient (raster, gradient_dimension, denominator_unit)
# Save the output
gradient _raster.save("C:/output/ndvi_stdtime_gradient.crf")
Vous avez un commentaire à formuler concernant cette rubrique ?