Global Raster functions.
These functions are applied to the raster data to create a
processed product on disk, using save() method or generate_raster().
Global functions cannot be used for visualization using dynamic image processing. They cannot be applied to layers that are added to a map for on-the-fly image processing or visualized inline within the Jupyter notebook.
Functions can be applied to ImageryLayer or Raster objects. The output of a global function is a new ImageryLayer or Raster object with the function applied.
It must be then persisted using the save() method.
boundary_clean
- arcgis.raster.functions.gbl.boundary_clean(input_raster: Raster | ImageryLayer, sort_type: str = 'NO_SORT', number_of_runs: str = 'TWO_WAY')
The boundary_clean function smooths the boundary between zones in a raster.
The function generalizes, or simplifies, rasters by smoothing the boundaries between zones. The function provides options for controlling how the cells of the zones in the input influence the smoothing and the amount of smoothing that will be applied. Each input cell is evaluated using its eight immediate neighbors.
The smoothing process first sorts the neighbor cells by a particular priority. The priority determines which zone from the neighboring cells can replace the value of the processing cell in the output.
Function available in ArcGIS Image Server 10.9 and higher. For more information, see Boundary Clean function
Parameter
Description
input_raster
Required ImageryLayer or Raster object. The input raster for which the boundary between zones will be smoothed. It must be of integer type.
sort_type
Optional string. Specifies the type of sorting to use in the smoothing process. The sorting determines the priority by which cells can expand into their neighbors. The sorting can be done based on zone value or zone area. The available choices are: [‘NO_SORT’, ‘DESCEND’, ‘ASCEND’] The default is: ‘NO_SORT’.
NO_SORT- The zones are not sorted by size. Zones with larger values will have a higher priority to expand into zones with smaller values in the smoothed output. This is the default.DESCEND- Sorts zones in descending order by size. Zones with larger total areas have a higher priority to expand into zones with smaller total areas. This option will tend to eliminate or reduce the prevalence of cells from smaller zones in the smoothed output.ASCEND- Sorts zones in ascending order by size. Zones with smaller total areas have a higher priority to expand into zones with larger total areas. This option will tend to preserve or increase the prevalence of cells from smaller zones in the smoothed output.
number_of_runs
Optional string. Specifies the number of times the smoothing process will take place, twice or once.
TWO_WAY(true) - Performs an expansion and shrinking operation two times. For the first time the operation is performed according to the specified sorting type. Then an additional expansion and shrinking operation is performed, but with the priority reversed. This is the default.ONE_WAY(false) - Performs the expansion and shrinking operation once, according to the sorting type.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Smooth the boundaries between zones in a classified raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") imagery_layer = ImageryLayer("https://myserver/server/rest/services/classified/ImageServer", gis=gis) # Alternatively, create the input layer from a portal item. imagery_layer = gis.content.search("title:classified", item_type="Imagery Layer")[0].layers[0] boundary_clean_output = boundary_clean(input_raster=imagery_layer, sort_type="NO_SORT", number_of_runs="TWO_WAY") boundary_clean_item = boundary_clean_output.save()
corridor
- arcgis.raster.functions.gbl.corridor(in_distance_raster1: Raster | ImageryLayer, in_distance_raster2: Raster | ImageryLayer)
Calculates the sum of two accumulative cost distance rasters with the option to apply a threshold based on percentage or accumulative cost.
The input rasters should be distance accumulation and back direction rasters output from the
distance_accumulationordistance_allocationfunction. These should be based on cost distance, and the same parameter settings should be used when creating the layers for each source. No parameters that depend on directionality (horizontal factor, vertical factor, and travel direction) should be used in creating these rasters.For more information, see Least Cost Corridor function
Parameter
Description
in_distance_raster1
Required ImageryLayer or Raster object. The input raster representing accumulative cost distance from the first source.
It should be an accumulated cost distance output from the
distance_accumulationordistance_allocationfunction.in_distance_raster2
Required ImageryLayer or Raster object. The input raster representing accumulative cost distance from the second source.
It should be an accumulated cost distance output from the
distance_accumulationordistance_allocationfunction.- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Create a corridor from two accumulated distance rasters. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") distance_raster_1 = ImageryLayer("https://myserver/server/rest/services/distance_1/ImageServer", gis=gis) distance_raster_2 = ImageryLayer("https://myserver/server/rest/services/distance_2/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. distance_raster_1 = gis.content.search("title:distance 1", item_type="Imagery Layer")[0].layers[0] distance_raster_2 = gis.content.search("title:distance 2", item_type="Imagery Layer")[0].layers[0] corridor_output = corridor( in_distance_raster1=distance_raster_1, in_distance_raster2=distance_raster_2, ) corridor_item = corridor_output.save("corridor_output")
distance_accumulation
- arcgis.raster.functions.gbl.distance_accumulation(in_source_data: Raster | ImageryLayer | FeatureLayer, in_barrier_data: Raster | ImageryLayer | FeatureLayer | None = None, in_surface_raster: Raster | ImageryLayer | None = None, in_cost_raster: Raster | ImageryLayer | None = None, in_vertical_raster: Raster | ImageryLayer | None = None, vertical_factor: str = 'BINARY 1 -30 30', in_horizontal_raster: Raster | ImageryLayer | None = None, horizontal_factor: str = 'BINARY 1 45', source_initial_accumulation: int | None = None, source_maximum_accumulation: int | None = None, source_cost_multiplier: int | None = None, source_direction: str = 'FROM_SOURCE', distance_method: str = 'PLANAR', output_back_direction_raster_name: str | None = None, output_source_direction_raster_name: str | None = None, output_source_location_raster_name: str | None = None)
Calculates accumulated distance for each cell to sources, allowing for straight-line distance, cost distance, and true surface distance, as well as vertical and horizontal cost factors.
Use a consistent input for the Raster input to that function. This will ensure that the features are properly converted to a raster dataset using the same cell size, extent, and spatial reference.
The primary output distance accumulation raster name is specified when
save()is called on the returned raster. Theoutput_back_direction_raster_name,output_source_direction_raster_name, andoutput_source_location_raster_nameparameters are used only for optional additional outputs; providing a value for any of these parameters requests that the corresponding optional raster be generated.For more information, see Distance Accumulation function
Parameter
Description
in_source_data
Required ImageryLayer, or Raster or FeatureLayer object. The input source locations.
This is a layer that identifies the cells or locations from or to which the least accumulated cost distance for every output cell location is calculated. This parameter can have either a raster layer input or a feature layer input. For rasters, the input type can be integer or floating point.
in_barrier_data
Optional ImageryLayer, or Raster or FeatureLayer object. The input layer that defines the barriers.
This parameter can have either a raster layer input or a feature layer input. The dataset must contain NoData where there are no barriers. Barriers are represented by valid values including zero. The barriers can be defined by an integer or floating-point raster.
in_surface_raster
Optional ImageryLayer or Raster object. A raster defining the elevation values at each cell location. The values are used to calculate the actual surface distance covered when passing between cells.
in_cost_raster
Optional ImageryLayer or Raster object. A raster defining the impedance or cost to move planimetrically through each cell.
The value at each cell location represents the cost-per-unit distance for moving through the cell. Each cell location value is multiplied by the cell resolution while also compensating for diagonal movement to obtain the total cost of passing through the cell.
The values of the cost raster can be integer or floating point, but they cannot be negative or zero (you cannot have a negative or zero cost).
in_horizontal_raster
Optional ImageryLayer or Raster object. A raster defining the horizontal direction at each cell. The values on the raster must be integers ranging from 0 to 360, with 0 degrees being north, or toward the top of the screen, and increasing clockwise. Flat areas should be given a value of -1. The values at each location will be used in conjunction with the {horizontal_factor} to determine the horizontal cost incurred when moving from a cell to its neighbors.
in_vertical_raster
Optional ImageryLayer or Raster object. Raster defining the vertical (z) value used for calculating the slope used to identify the vertical factor incurred when moving from one cell to another.
horizontal_factor
Optional string. The Horizontal Factor defines the relationship between the horizontal cost factor and the horizontal relative moving angle.
vertical_factor
Optional string. The Vertical Factor defines the relationship between the vertical cost factor and the vertical relative moving angle (VRMA)
distance_method
Optional string. Determines whether to calculate the distance using a planar (flat earth) or a geodesic (ellipsoid) method.
Planar - Planar measurements use 2D Cartesian mathematics to calculate length and area. The option is only available when measuring in a projected coordinate system and the 2D plane of that coordinate system will be used as the basis for the measurements. This is the default.
Geodesic - The shortest line between two points on the earth’s surface on a spheroid (ellipsoid). Therefore, regardless of input or output projection, the results do not change.
Note
One use for a geodesic line is when you want to determine the shortest distance between two cities for an airplane’s flight path. This is also known as a great circle line if based on a sphere rather than an ellipsoid.
source_initial_accumulation
Optional int. The starting cost from which to begin the cost calculations.
Allows for the specification of the fixed cost associated with a source. Instead of starting at a cost of zero, the cost algorithm will begin with the value set by source_start_cost.
The values must be zero or greater. The default is 0.
source_maximum_accumulation
Optional int. The cost capacity for the traveler for a source.
The cost calculations continue for each source until the specified capacity is reached.
The values must be greater than zero. The default capacity is to the edge of the output raster.
source_cost_multiplier
Optional int. Multiplier to apply to the cost values. Allows for control of the mode of travel or the magnitude at a source. The greater the multiplier, the greater the cost to move through each cell. The values must be greater than zero. The default is 1.
source_direction
Optional string. Defines the direction of the traveler when applying horizontal and vertical factors, the source resistance rate, and the source starting cost. Possible values: FROM_SOURCE, TO_SOURCE. Default value is FROM_SOURCE.
output_back_direction_raster_name
Optional string. Name of the optional back_direction_raster. Set this parameter in order to generate the back_direction_raster. If not set, the back_direction_raster will not be generated. If set, the output of the function will be a named tuple.
output_source_direction_raster_name
Optional string. Name of the optional source_direction_raster. Set this parameter in order to generate the source_direction_raster. If not set, the source_direction_raster will not be generated. If set, the output of the function will be a named tuple.
output_source_location_raster_name
Optional string. Name of the optional source_location_raster. Set this parameter in order to generate the source_location_raster. If not set, the source_location_raster will not be generated. If set, the output of the function will be a named tuple.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example 1: Generate the primary distance accumulation raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer from arcgis.features import FeatureLayer gis = GIS("home") sources = FeatureLayer("https://myserver/server/rest/services/sources/FeatureServer/0", gis=gis) barriers = FeatureLayer("https://myserver/server/rest/services/barriers/FeatureServer/0", gis=gis) cost_raster = ImageryLayer("https://myserver/server/rest/services/cost/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. sources = gis.content.search("title:sources", item_type="Feature Layer")[0].layers[0] barriers = gis.content.search("title:barriers", item_type="Feature Layer")[0].layers[0] cost_raster = gis.content.search("title:cost", item_type="Imagery Layer")[0].layers[0] distance_accumulation_output = distance_accumulation( in_source_data=sources, in_barrier_data=barriers, in_cost_raster=cost_raster, source_direction="FROM_SOURCE", distance_method="PLANAR", ) distance_accumulation_item = distance_accumulation_output.save("distance_accumulation_output") # Usage Example 2: Generate optional back direction, source direction, # and source location rasters. Specifying each optional output raster # name indicates that the corresponding raster should be generated. distance_accumulation_output = distance_accumulation( in_source_data=sources, in_barrier_data=barriers, in_cost_raster=cost_raster, source_direction="FROM_SOURCE", distance_method="PLANAR", output_back_direction_raster_name="back_direction_output", output_source_direction_raster_name="source_direction_output", output_source_location_raster_name="source_location_output", ) distance_accumulation_result = distance_accumulation_output.save("distance_accumulation_output")
distance_allocation
- arcgis.raster.functions.gbl.distance_allocation(in_source_data: Raster | ImageryLayer | FeatureLayer, in_barrier_data: Raster | ImageryLayer | FeatureLayer | None = None, in_surface_raster: Raster | ImageryLayer | None = None, in_cost_raster: Raster | ImageryLayer | None = None, in_vertical_raster: Raster | ImageryLayer | None = None, vertical_factor: str = 'BINARY 1 -30 30', in_horizontal_raster: Raster | ImageryLayer | None = None, horizontal_factor: str = 'BINARY 1 45', source_field: str | None = None, source_initial_accumulation: int | None = None, source_maximum_accumulation: int | None = None, source_cost_multiplier: int | None = None, source_direction: str = 'FROM_SOURCE', distance_method: str = 'PLANAR', output_distance_accumulation_raster_name: str | None = None, output_back_direction_raster_name: str | None = None, output_source_direction_raster_name: str | None = None, output_source_location_raster_name: str | None = None)
Calculates distance allocation for each cell to the provided sources based on straight- line distance, cost distance, and true surface distance, as well as vertical and horizontal cost factors.
The primary output distance allocation raster name is specified when
save()is called on the returned raster. Theoutput_distance_accumulation_raster_name,output_back_direction_raster_name,output_source_direction_raster_name, andoutput_source_location_raster_nameparameters are used only for optional additional outputs; providing a value for any of these parameters requests that the corresponding optional raster be generated.For more information, see Distance Allocation function
Parameter
Description
in_source_data
Required ImageryLayer, Raster or FeatureLayer object. The input source locations.
This is a layer that identifies the cells or locations from or to which the least accumulated cost distance for every output cell location is calculated. This parameter can have either a raster layer input or a feature layer input. For rasters, the input type can be integer or floating point.
in_barrier_data
Optional ImageryLayer, Raster or FeatureLayer object. The input layer that defines the barriers.
This parameter can have either a raster layer input or a feature layer input. The dataset must contain NoData where there are no barriers. Barriers are represented by valid values including zero. The barriers can be defined by an integer or floating-point raster.
in_surface_raster
Optional ImageryLayer or Raster object. A raster defining the elevation values at each cell location. The values are used to calculate the actual surface distance covered when passing between cells.
in_cost_raster
Optional ImageryLayer or Raster object. A raster defining the impedance or cost to move planimetrically through each cell.
The value at each cell location represents the cost-per-unit distance for moving through the cell. Each cell location value is multiplied by the cell resolution while also compensating for diagonal movement to obtain the total cost of passing through the cell.
The values of the cost raster can be integer or floating point, but they cannot be negative or zero (you cannot have a negative or zero cost).
in_vertical_raster
Optional ImageryLayer or Raster object. Raster defining the vertical (z) value used for calculating the slope used to identify the vertical factor incurred when moving from one cell to another.
vertical_factor
Optional string. The Vertical Factor defines the relationship between the vertical cost factor and the vertical relative moving angle (VRMA)
in_horizontal_raster
Optional ImageryLayer or Raster object. A raster defining the horizontal direction at each cell. The values on the raster must be integers ranging from 0 to 360, with 0 degrees being north, or toward the top of the screen, and increasing clockwise. Flat areas should be given a value of -1. The values at each location will be used in conjunction with the {horizontal_factor} to determine the horizontal cost incurred when moving from a cell to its neighbors.
horizontal_factor
Optional string. The Horizontal Factor defines the relationship between the horizontal cost factor and the horizontal relative moving angle.
source_field
Optional string. The field used to assign values to the source locations. It must be an integer type. If the Value Raster has been set, the values in that input will take precedence over any setting for the source field.
source_initial_accumulation
Optional int. The starting cost from which to begin the cost calculations.
Allows for the specification of the fixed cost associated with a source. Instead of starting at a cost of zero, the cost algorithm will begin with the value set by source_start_cost.
The values must be zero or greater. The default is 0.
source_maximum_accumulation
Optional int. The cost capacity for the traveler for a source.
The cost calculations continue for each source until the specified capacity is reached.
The values must be greater than zero. The default capacity is to the edge of the output raster.
source_cost_multiplier
Optional int. Multiplier to apply to the cost values. Allows for control of the mode of travel or the magnitude at a source. The greater the multiplier, the greater the cost to move through each cell. The values must be greater than zero. The default is 1.
source_direction
Optional string. Defines the direction of the traveler when applying horizontal and vertical factors, the source resistance rate, and the source starting cost. Possible values: FROM_SOURCE, TO_SOURCE. Default value is FROM_SOURCE.
distance_method
Optional string. Determines whether to calculate the distance using a planar (flat earth) or a geodesic (ellipsoid) method.
Planar - Planar measurements use 2D Cartesian mathematics to calculate length and area. The option is only available when measuring in a projected coordinate system and the 2D plane of that coordinate system will be used as the basis for the measurements. This is the default.
Geodesic - The shortest line between two points on the earth’s surface on a spheroid (ellipsoid). Therefore, regardless of input or output projection, the results do not change.
Note
One use for a geodesic line is when you want to determine the shortest distance between two cities for an airplane’s flight path. This is also known as a great circle line if based on a sphere rather than an ellipsoid.
output_distance_accumulation_raster_name
Optional string. Name of the optional distance_accumulation_raster. Set this parameter in order to generate the distance_accumulation_raster. If not set, the distance_accumulation_raster will not be generated. If set, the output of the function will be a named tuple.
output_back_direction_raster_name
Optional string. Name of the optional back_direction_raster. Set this parameter in order to generate the back_direction_raster. If not set, the back_direction_raster will not be generated. If set, the output of the function will be a named tuple.
output_source_direction_raster_name
Optional string. Name of the optional source_direction_raster. Set this parameter in order to generate the source_direction_raster. If not set, the source_direction_raster will not be generated. If set, the output of the function will be a named tuple.
output_source_location_raster_name
Optional string. Name of the optional source_location_raster. Set this parameter in order to generate the source_location_raster. If not set, the source_location_raster will not be generated. If set, the output of the function will be a named tuple.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example 1: Generate the primary distance allocation raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer from arcgis.features import FeatureLayer gis = GIS("home") sources = FeatureLayer("https://myserver/server/rest/services/sources/FeatureServer/0", gis=gis) barriers = FeatureLayer("https://myserver/server/rest/services/barriers/FeatureServer/0", gis=gis) cost_raster = ImageryLayer("https://myserver/server/rest/services/cost/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. sources = gis.content.search("title:sources", item_type="Feature Layer")[0].layers[0] barriers = gis.content.search("title:barriers", item_type="Feature Layer")[0].layers[0] cost_raster = gis.content.search("title:cost", item_type="Imagery Layer")[0].layers[0] distance_allocation_output = distance_allocation( in_source_data=sources, in_barrier_data=barriers, in_cost_raster=cost_raster, source_field="SourceID", source_direction="FROM_SOURCE", distance_method="PLANAR", ) distance_allocation_item = distance_allocation_output.save("distance_allocation_output") # Usage Example 2: Generate optional distance accumulation, back direction, # source direction, and source location rasters. Specifying each optional # output raster name indicates that the corresponding raster should be generated. distance_allocation_output = distance_allocation( in_source_data=sources, in_barrier_data=barriers, in_cost_raster=cost_raster, source_field="SourceID", source_direction="FROM_SOURCE", distance_method="PLANAR", output_distance_accumulation_raster_name="distance_accumulation_output", output_back_direction_raster_name="back_direction_output", output_source_direction_raster_name="source_direction_output", output_source_location_raster_name="source_location_output", ) distance_allocation_result = distance_allocation_output.save("distance_allocation_output")
expand
- arcgis.raster.functions.gbl.expand(input_raster: Raster | ImageryLayer, number_of_cells: int, zone_values: list | str)
Expands specified zones of a raster by a specified number of cells.
Expands specified zones of a raster by zones by a specified number of cells.
The specified zone values are considered foreground zones, while the remaining zone values are considered background zones. With this tool, the foreground zones are allowed to expand into the background zones.
NoData cells are always considered background cells; therefore, neighboring cells of any value can expand into NoData cells. NoData cells will never expand into their neighbors.
For more information, See Expand function
Parameter
Description
input_raster
Required ImageryLayer or Raster object. Integer raster containing the zones to be expanded.
number_of_cells
Required int. The number of cells to expand by. The value must be integer, and can be 1 or greater.
zone_values
Required list or string. The list of zones to expand. The zone values must be integer, and they can be in any order. The zone values can be specified as a list or as a string. If specified as a string and if it is required to specify multiple zones, use a semicolon (“;”) to separate the zone values.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Expand selected zones by two cells. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") classified_raster = ImageryLayer("https://myserver/server/rest/services/classified/ImageServer", gis=gis) # Alternatively, create the input layer from a portal item. classified_raster = gis.content.search("title:classified", item_type="Imagery Layer")[0].layers[0] expand_output = expand( input_raster=classified_raster, number_of_cells=2, zone_values=[1, 2, 3], ) expand_item = expand_output.save("expand_output")
fill
- arcgis.raster.functions.gbl.fill(input_surface_raster: Raster | ImageryLayer, zlimit: float | None = None)
Fills sinks in a surface raster to remove small imperfections in the data
Locates and fills sinks and peaks in an elevation surface raster to remove small imperfections in the data. The function will fill in an iterative process until all sinks are filled within the specified Z Limit.
When an elevation surface is created with Ortho Mapping tools or by other means, there are often small but significant errors in the form of sinks and peaks in the data. In photogrammetry, sinks and peaks are often referred to as holes and spikes. Because surface data is often used in modeling, such as hydrologic modeling, it is important to correct these sink and peak errors in a manner consistent with the surrounding data.
A sink is a pixel with an undefined drainage direction; no pixels surrounding it are lower. The pour point is the boundary pixel with the lowest elevation for the contributing area of a sink. If the sink were filled with water, this is the point where water would pour out.
For more information, see Fill function
Parameter
Description
input_surface_raster
Required ImageryLayer or Raster object. A single band raster elevation.
zlimit
Optional float. The maximum elevation difference between a sink and its pour point to be filled. If the difference in z-values between a sink and its pour point is greater than the z_limit, that sink will not be filled. The value for z-limit must be greater than zero. Unless a value is specified for this parameter, all sinks will be filled, regardless of depth.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Fill sinks in an elevation surface raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") surface_raster = ImageryLayer("https://myserver/server/rest/services/elevation/ImageServer", gis=gis) # Alternatively, create the input layer from a portal item. surface_raster = gis.content.search("title:elevation", item_type="Imagery Layer")[0].layers[0] fill_output = fill( input_surface_raster=surface_raster, zlimit=10, ) fill_item = fill_output.save("fill_output")
flow_accumulation
- arcgis.raster.functions.gbl.flow_accumulation(input_flow_direction_raster: Raster | ImageryLayer, input_weight_raster: Raster | ImageryLayer | None = None, data_type: str = 'FLOAT', flow_direction_type: str = 'D8')
Creates a raster layer of accumulated flow into each cell. A weight factor can optionally be applied.
The result is a raster layer of accumulated flow to each cell, as determined by accumulating the weight for all cells that flow into each downslope cell. If no weight raster is provided, a weight of 1 is applied to each cell, and the value of cells in the output raster is the number of cells that flow into each cell.
The function supports three flow modeling methods for computing accumulated flow, including D8, Multiple Flow Direction (MFD) and D-Infinity (DINF).
The flow direction raster can be created using the
flow_direction.For more information, see Flow Accumulation function
Parameter
Description
input_flow_direction_raster
Required ImageryLayer or Raster object. The input raster that shows the direction of flow out of each cell. The flow direction raster can be created using the
flow_direction.input_weight_raster
Optional ImageryLayer or Raster object. Raster for applying a weight to each cell.
If no weight raster is specified, a default weight of 1 will be applied to each cell.
data_type
Optional string. The output accumulation raster can be integer or floating point type.
Choice List: “INTEGER”, “FLOAT”
FLOAT- The output raster will be floating point type. . This is the default.INTEGER- The output raster will be integer type.
The default value is ‘FLOAT’.
flow_direction_type
Optional string. Specifies the flow direction type to use.
Choice list: [‘D8’, ‘MFD’, ‘DINF’]
D8is for the D8 flow direction type. This is the default.MFDis for the Multi Flow Direction type.DINFis for the D-Infinity type.
The default value is ‘D8’.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Calculate accumulated flow from a flow direction raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") flow_direction_raster = ImageryLayer("https://myserver/server/rest/services/flow_direction/ImageServer", gis=gis) weight_raster = ImageryLayer("https://myserver/server/rest/services/weight/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. flow_direction_raster = gis.content.search("title:flow direction", item_type="Imagery Layer")[0].layers[0] weight_raster = gis.content.search("title:weight", item_type="Imagery Layer")[0].layers[0] flow_accumulation_output = flow_accumulation( input_flow_direction_raster=flow_direction_raster, input_weight_raster=weight_raster, data_type="FLOAT", flow_direction_type="D8", ) flow_accumulation_item = flow_accumulation_output.save("flow_accumulation_output")
flow_direction
- arcgis.raster.functions.gbl.flow_direction(input_surface_raster: Raster | ImageryLayer, force_flow: str = 'NORMAL', flow_direction_type: str = 'D8', generate_out_drop_raster: bool = False)
The
flow_directiontask creates a raster of flow direction from each cell to its steepest downslope neighbor.This task supports three flow modeling algorithms. Those are D8, Multi Flow Direction (MFD), and D-Infinity (DINF).
D8 flow modeling algorithm
The D8 flow method models flow direction from each cell to its steepest downslope neighbor.
The output of the FlowDirection task run with the D8 flow direction type is an integer raster whose values range from 1-255. The values for each direction from the center are the following:
For example, if the direction of steepest drop was to the left of the current processing cell, its flow direction would be coded at 16.
The following are additional considerations for using the D8 flow method:
If a cell is lower than its eight neighbors, that cell is given the value of its lowest neighbor, and flow is defined toward this cell. If multiple neighbors have the lowest value, the cell is still given this value, but flow is defined with one of the two methods explained below. This is used to filter out one-cell sinks, which are considered noise.
If a cell has the same change in z-value in multiple directions and that cell is part of a sink, the flow direction is referred to as undefined. In such cases, the value for that cell in the output flow direction raster will be the sum of those directions. For example, if the change in z-value is the same both to the right (flow direction = 1) and down (flow direction = 4), the flow direction for that cell is 5.
If a cell has the same change in z-value in multiple directions and is not part of a sink, the flow directions is assigned with a lookup table defining the most likely direction. See Greenlee (1987).
The output drop raster is calculated as the difference in z-value divided by the path length between the cell centers, expressed in percentages. For adjacent cells, this is analogous to the percent slope between cells. Across a flat area, the distance becomes the distance to the nearest cell of lower elevation. The result is a map of percent rise in the path of steepest descent from each cell.
When calculating a drop raster in flat areas, the distance to diagonally adjacent cells (1.41421 * cell size) is approximated by 1.5 * cell size for improved performance.
With the forceFlow parameter set to the default value False, a cell at the edge of the surface raster will flow towards the inner cell with the steepest z-value. If the drop is less than or equal to zero, the cell will flow out of the surface raster.
MFD flow modeling algorithm
The MFD algorithm, described by Qin et al. (2007), partitions flow from a cell to all downslope neighbors. A flow-partition exponent is created from an adaptive approach based on local terrain conditions and is used to determine fraction of flow draining to all downslope neighbors.
When the MFD flow direction output is added to a map, it only displays the D8 flow direction. As MFD flow directions have potentially multiple values tied to each cell (each value corresponds to proportion of flow to each downslope neighbor), it is not easily visualized. However, an MFD flow direction output raster is an input recognized by the FlowAccumulation task that would utilize the MFD flow directions to proportion and accumulate flow from each cell to all downslope neighbors.
DINF flow modeling algorithm
The DINF flow method, described by Tarboton (1997), determines flow direction as the steepest downward slope on eight triangular facets formed in a 3x3 cell window centered on the cell of interest. The flow direction output is a floating-point raster represented as a single angle in degrees going counter-clockwise from 0 (due east) to 360 (also due east).
Parameter
Description
input_surface_raster
Required ImageryLayer or Raster object. The input raster representing a continuous elevation surface.
force_flow
Optional string. Specifies if edge cells will always flow outward or follow normal flow rules.
Choice list: [‘NORMAL’, ‘FORCE’]
The default value is ‘NORMAL’.
flow_direction_type
Optional string. Specifies the flow direction type to use.
Choice list: [‘D8’, ‘MFD’, ‘DINF’]
D8is for the D8 flow direction type. This is the default.MFDis for the Multi Flow Direction type.DINFis for the D-Infinity type.
The default value is ‘D8’.
generate_out_drop_raster
Optional bool. Determines whether out_drop_raster should be generated or not. Set this parameter to True, in order to generate the out_drop_raster. If set to true, the output will be a named tuple with name values being output_flow_direction_service and output_drop_service.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Generate flow direction and drop rasters from a surface raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") in_raster = ImageryLayer("https://myserver/server/rest/services/elevation/ImageServer", gis=gis) # Alternatively, create the input layer from a portal item. in_raster = gis.content.search("title:elevation", item_type="Imagery Layer")[0].layers[0] flow_direction_output = flow_direction(input_surface_raster=in_raster, force_flow="NORMAL", flow_direction_type="D8", generate_out_drop_raster=True) out_var = flow_direction_output.save() out_var.output_flow_direction_service # gives you the output flow direction imagery layer item out_var.output_drop_service # gives you the output drop raster imagery layer item
flow_distance
- arcgis.raster.functions.gbl.flow_distance(input_stream_raster: Raster | ImageryLayer, input_surface_raster: Raster | ImageryLayer, input_flow_direction_raster: Raster | ImageryLayer | None = None, distance_type: str = 'VERTICAL', flow_direction_type: str = 'D8', statistics_type: str = 'MINIMUM')
Computes, for each cell, the horizontal or vertical component of downslope distance, following the flow paths, to cells on a stream into which they flow. In case of multiple flow paths, minimum, weighted mean, or maximum flow distance can be computed. If an optional flow direction raster is provided, the down slope direction(s) will be limited to those defined by the input flow direction raster.
To limit downslope directions along which flow distance is measured, provide an optional input flow direction raster that can be derived using the Flow Direction function. Choose from D8, D-Infinity (DINF) and multi-flow direction (MFD) flow models while generating an optional input flow direction raster.
For more information, see Flow Distance function
Parameter
Description
input_stream_raster
Required ImageryLayer or Raster object. An input raster that represents a linear stream network
input_surface_raster
Required ImageryLayer or Raster object. The input raster representing a continuous elevation surface.
input_flow_direction_raster
Optional ImageryLayer or Raster object. The input raster that shows the direction of flow out of each pixel.
When a flow direction raster is provided, the down slope direction(s) will be limited to those defined by the input flow directions.
The flow direction raster can be created by persisting the layer created using the
flow_direction.distance_type
Optional string. VERTICAL or HORIZONTAL distance to compute; if not specified, VERTICAL distance is computed.
flow_direction_type
Optional string. Defines the type of the input flow direction raster.
D8 - The input flow direction raster is of type D8. This is the default.
MFD - The input flow direction raster is of type Multi Flow Direction (MFD).
DINF - The input flow direction raster is of type D-Infinity (DINF).
statistics_type
Optional string. Determines the statistics type used to compute flow distance over multiple flow paths. If there is only a single flow path from each cell to a cell on the stream, all statistics types produce the same result.
MINIMUM - Where multiple flow paths exist, minimum flow distance in computed. This is the default.
WEIGHTED_MEAN - Where multiple flow paths exist, a weighted mean of flow distance is computed. Flow proportion from a cell to its downstream neighboring cells are used as weights for computing weighted mean.
MAXIMUM - When multiple flow paths exist, maximum flow distance is computed.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Calculate the minimum vertical downslope distance to stream cells. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") stream_raster = ImageryLayer("https://myserver/server/rest/services/streams/ImageServer", gis=gis) surface_raster = ImageryLayer("https://myserver/server/rest/services/elevation/ImageServer", gis=gis) flow_direction_raster = ImageryLayer("https://myserver/server/rest/services/flow_direction/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. stream_raster = gis.content.search("title:streams", item_type="Imagery Layer")[0].layers[0] surface_raster = gis.content.search("title:elevation", item_type="Imagery Layer")[0].layers[0] flow_direction_raster = gis.content.search("title:flow direction", item_type="Imagery Layer")[0].layers[0] flow_distance_output = flow_distance( input_stream_raster=stream_raster, input_surface_raster=surface_raster, input_flow_direction_raster=flow_direction_raster, distance_type="VERTICAL", flow_direction_type="D8", statistics_type="MINIMUM", ) flow_distance_item = flow_distance_output.save("flow_distance_output")
flow_length
- arcgis.raster.functions.gbl.flow_length(input_flow_direction_raster: Raster | ImageryLayer, direction_measurement: str = 'DOWNSTREAM', input_weight_raster: Raster | ImageryLayer | None = None)
Creates a raster layer of upstream or downstream distance, or weighted distance, along the flow path for each cell.
A primary use of the function is to calculate the length of the longest flow path within a given basin. This measure is often used to calculate the time of concentration of a basin. This is done using the Upstream option. The function can also be used to create distance-area diagrams of hypothetical rainfall and runoff events using the weight raster as an impedance to movement downslope.
For more information, see Flow Length function
Parameter
Description
input_flow_direction_raster
Required ImageryLayer or Raster object. Flow-direction raster showing the direction of flow out of each cell. The flow direction raster can be created by running the Flow Direction function.
direction_measurement
Optional string. The direction of measurement along the flow path.
DOWNSTREAM - Calculates the downslope distance along the flow path, from each cell to a sink or outlet on the edge of the raster. this is the default.
UPSTREAM - Calculates the longest upslope distance along the flow path, from each cell to the top of the drainage divide.
input_weight_raster
Optional ImageryLayer or Raster object. An optional input raster for applying a weight to each cell. If no weight raster is specified, a default weight of 1 will be applied to each cell.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Calculate upstream flow length using a weight raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") flow_direction_raster = ImageryLayer("https://myserver/server/rest/services/flow_direction/ImageServer", gis=gis) weight_raster = ImageryLayer("https://myserver/server/rest/services/weight/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. flow_direction_raster = gis.content.search("title:flow direction", item_type="Imagery Layer")[0].layers[0] weight_raster = gis.content.search("title:weight", item_type="Imagery Layer")[0].layers[0] flow_length_output = flow_length( input_flow_direction_raster=flow_direction_raster, direction_measurement="UPSTREAM", input_weight_raster=weight_raster, ) flow_length_item = flow_length_output.save("flow_length_output")
kernel_density
- arcgis.raster.functions.gbl.kernel_density(in_features: FeatureLayer, population_field: str, cell_size: float | None = None, search_radius: float | None = None, area_unit_scale_factor: str = 'SQUARE_MAP_UNITS', out_cell_values: str = 'DENSITIES', method: str = 'PLANAR', in_barriers=None)
Calculates a magnitude-per-unit area from point or polyline features using a kernel function to fit a smoothly tapered surface to each point or polyline. A barrier can be used to alter the influence of a feature while calculating kernel density.
Very large or very small values in the population_field parameter can give results that may not be intuitive. If the mean of the population_field values is much bigger than 1 (for example, as with city populations), the default search radius may be very small, resulting in small rings around the input points. If the mean of the Population Field values is much smaller than 1, the calculated bandwidth may seem unreasonably large. In these cases, you may want to enter your own search_radius.
For more information, see Kernel Density function
Parameter
Description
in_features
Required FeatureLayer. The input point or line features for which to calculate the density
population_field
Required string. Field denoting population values for each feature. It is the count or quantity to be spread across the landscape to create a continuous surface. Values in the population field may be integer or floating point.
cell_size
Optional float. The pixel size for the output raster. If the cell size has been set in the geoprocessing Environments it will be the default.
search_radius
Optional float. The search radius within which to calculate density. Units are based on the linear unit of the projection.
area_unit_scale_factor
Optional string. The desired area units of the output density values.
SQUARE_MAP_UNITS-For the square of the linear units of the output spatial reference.
SQUARE_MILES-For (U.S.) miles.
SQUARE_KILOMETERS-For kilometers.
ACRES For (U.S.) acres.
HECTARES-For hectares.
SQUARE_METERS-For meters.
SQUARE_YARDS-For (U.S.) yards.
SQUARE_FEET-For (U.S.) feet.
SQUARE_INCHES-For (U.S.) inches.
SQUARE_CENTIMETERS-For centimeters.
SQUARE_MILLIMETERS-For millimeters.
out_cell_values
Optional string. Determines what the values in the output raster represent.
DENSITIES-The output values represent the predicted density value. This is the default.
EXPECTED_COUNTS-The output values represent the predicted amount of the phenomenon within each pixel. Since the pixel value is linked to the specified Cellsize, the resulting raster cannot be resampled to a different pixel size and still represent the amount of the phenomenon.
method
Optional string. Determines whether to use a shortest path on a spheroid (geodesic) or a flat earth (planar) method.
PLANAR-Uses planar distances between the features. This is the default.
GEODESIC-Uses geodesic distances between features. This method takes into account the curvature of the spheroid and correctly deals with data near the poles and the International dateline.
in_barriers
Optional FeatureLayer. The dataset that defines the barriers. The barriers can be a feature layer of polyline or polygon features. (Parameter available in ArcGIS Image Server 10.9 and higher.)
- Returns:
output raster
# Usage Example: Create a population density raster from point features. from arcgis.gis import GIS from arcgis.features import FeatureLayer gis = GIS("home") point_features = FeatureLayer("https://myserver/server/rest/services/points/FeatureServer/0", gis=gis) # Alternatively, create the input layer from a portal item. point_features = gis.content.search("title:points", item_type="Feature Layer")[0].layers[0] kernel_density_output = kernel_density( in_features=point_features, population_field="POPULATION", cell_size=30, search_radius=1000, area_unit_scale_factor="SQUARE_KILOMETERS", out_cell_values="DENSITIES", method="PLANAR", ) kernel_density_item = kernel_density_output.save("kernel_density_output")
nibble
- arcgis.raster.functions.gbl.nibble(input_raster: Raster | ImageryLayer, input_mask_raster: Raster | ImageryLayer, nibble_values: str = 'ALL_VALUES', nibble_no_data: str = 'PRESERVE_NODATA', input_zone_raster: Raster | ImageryLayer | None = None)
Replaces selected cells of a raster with the value of their nearest neighbor. This is useful for editing areas of a raster in which the data may be erroneous.
Cells that are NoData in the Mask Raster define the locations where cell values in the input Raster will be nibbled (replaced). Any locations in the input Raster that are outside the mask area will not be nibbled, and will have the same value in the output raster as they have in the input raster.
For more information, see Nibble function
Parameter
Description
input_raster
Required ImageryLayer or Raster object. The input raster can be integer or floating-point. The input raster with the masked locations that will be replaced by the value of their nearest neighbor.
input_mask_raster
Required ImageryLayer or Raster object. The raster that identifies the locations in the input raster that will be replaced.
Cells with a value of NoData are considered to be within the masked area. In the output raster, these locations will be replaced by the value of their nearest neighbor in the input raster.
nibble_values
Optional string. Specifies whether NoData cells in the input raster can replace cells in the masked areas if they are the nearest neighbor. Possbile options are “ALL_VALUES” and “DATA_ONLY”. Default is “ALL_VALUES”
nibble_no_data
Optional string. Specifies whether NoData cells in the input raster that are within the masked area will be preserved or replaced. PRESERVE_NODATA or PROCESS_NODATA possible values; Default is PRESERVE_NODATA.
input_zone_raster
Optional ImageryLayer or Raster object. The input zone raster. For each zone, input cells that are within the mask will be replaced only by the nearest cell values within that same zone.
A zone is all the cells in a raster that have the same value, whether or not they are contiguous. The input zone layer defines the shape, values, and locations of the zones. The zone raster can be either integer or floating point type.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Replace masked cells using neighboring cell values. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") input_raster = ImageryLayer("https://myserver/server/rest/services/input/ImageServer", gis=gis) mask_raster = ImageryLayer("https://myserver/server/rest/services/mask/ImageServer", gis=gis) zone_raster = ImageryLayer("https://myserver/server/rest/services/zones/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. input_raster = gis.content.search("title:input", item_type="Imagery Layer")[0].layers[0] mask_raster = gis.content.search("title:mask", item_type="Imagery Layer")[0].layers[0] zone_raster = gis.content.search("title:zones", item_type="Imagery Layer")[0].layers[0] nibble_output = nibble( input_raster=input_raster, input_mask_raster=mask_raster, nibble_values="ALL_VALUES", nibble_no_data="PRESERVE_NODATA", input_zone_raster=zone_raster, ) nibble_item = nibble_output.save("nibble_output")
optimal_path_as_raster
- arcgis.raster.functions.gbl.optimal_path_as_raster(in_destination_data: Raster | ImageryLayer | FeatureLayer, in_distance_accumulation_raster: Raster | ImageryLayer, in_back_direction_raster: Raster | ImageryLayer, destination_field: str | None = None, path_type: str = 'EACH_ZONE')
Calculates the optimal path from destinations to sources.
This function produces an output raster that records the optimal path or paths from selected locations to the closest source cell defined within the distance accumulation surface, in terms of cost distance.
The results from the
distance_accumulationfunction are generally required to run the Optimal Path As Raster function. Running thedistance_accumulationfunction allows you to create the distance accumulation raster and back direction raster, which are required input raster layers to the Optimal Path As Raster function.The optimal path created can be a flow path based on D8 flow direction. To generate an optimal path in this way, use a D8 flow direction raster as input for the back direction raster or flow direction raster. You also need to supply an input distance accumulation raster; the input distance accumulation raster is not used to determine the path. Whether you use a constant raster or a digital elevation model (DEM), your path will be the same; only an attribute value on your path will vary.
For more information, see Optimal Path As Raster function
Parameter
Description
in_destination_data
Required FeatureLayer, ImageryLayer, or Raster object. A layer that identifies locations from which the optimal path is determined to the least costly source. This parameter can have either a raster layer input or a feature layer input.
If the input is a raster, it must consists of cells that have valid values (zero is a valid value), and the remaining cells must be assigned NoData.
in_distance_accumulation_raster
Required ImageryLayer or Raster object. The distance accumulation raster is used to determine the optimal path from the sources to the destinations.
The distance accumulation raster is usually created with the distance_accumulation or distance_allocation functions. Each cell in the distance accumulation raster represents the minimum accumulative cost distance over a surface from each cell to a set of source cells.
in_back_direction_raster
Required ImageryLayer or Raster object. The back direction raster contains calculated directions in degrees. The direction identifies the next cell along the optimal path back to the least accumulative cost source while avoiding barriers.
destination_field
Optional string. The field to be used to obtain values for the destination locations.
path_type
Optional string. A keyword defining the manner in which the values and zones on the input destination data will be interpreted in the cost path calculations.
EACH_ZONE - For each zone on the input destination data, a least-cost path is determined and saved on the output raster. With this option, the least-cost path for each zone begins at the cell with the lowest cost distance weighting in the zone. This is the default.
BEST_SINGLE - For all cells on the input destination data, the least-cost path is derived from the cell with the minimum of the least-cost paths to source cells.
EACH_CELL - For each cell with valid values on the input destination data, a least-cost path is determined and saved on the output raster. With this option, each cell of the input destination data is treated separately, and a least-cost path is determined for each from cell.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Create an optimal path raster from destinations to least-cost sources. from arcgis.gis import GIS from arcgis.raster import ImageryLayer from arcgis.features import FeatureLayer gis = GIS("home") destination_data = FeatureLayer("https://myserver/server/rest/services/destinations/FeatureServer/0", gis=gis) distance_accumulation_raster = ImageryLayer("https://myserver/server/rest/services/distance_accumulation/ImageServer", gis=gis) back_direction_raster = ImageryLayer("https://myserver/server/rest/services/back_direction/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. destination_data = gis.content.search("title:destinations", item_type="Feature Layer")[0].layers[0] distance_accumulation_raster = gis.content.search("title:distance accumulation", item_type="Imagery Layer")[0].layers[0] back_direction_raster = gis.content.search("title:back direction", item_type="Imagery Layer")[0].layers[0] optimal_path_output = optimal_path_as_raster( in_destination_data=destination_data, in_distance_accumulation_raster=distance_accumulation_raster, in_back_direction_raster=back_direction_raster, destination_field="DestinationID", path_type="EACH_ZONE", ) optimal_path_item = optimal_path_output.save("optimal_path_output")
region_group
- arcgis.raster.functions.gbl.region_group(in_raster: Raster | ImageryLayer, number_of_neighbor_cells: str = 'FOUR', zone_connectivity: str = 'WITHIN', add_link: str = 'ADD_LINK', excluded_value: int = 0)
Records, for each cell in the output, the identity of the connected region to which that cell belongs. A unique number is assigned to each region.
In general, the first region scanned receives the value one, the second two, and so on, until all regions are assigned a value. The scan moves from left to right, top to bottom. The values assigned to the output zones are based on when they are encountered in the scanning process.
For more information, see Region Group function
Parameter
Description
in_raster
Required ImageryLayer or Raster object. Integer raster for which unique connected regions of cells will be identified.
number_of_neighbor_cells
Optional string. The number of neighboring cells to use when evaluating connectivity between cells that define a region. The default is FOUR.
FOUR - Connectivity is evaluated for the four nearest (orthogonal) neighbors of each input cell.
EIGHT - Connectivity is evaluated for the eight nearest neighbors (both orthogonal and diagonal) of each input cell.
zone_connectivity
Optional string. Defines which cell values should be considered when testing for connectivity. The default is WITHIN.
WITHIN - Connectivity for a region is evaluated for input cells that are part of the same zone (cell value). The only cells that can be grouped are cells from the same zone that meet the spatial requirements of connectivity specified by the number_of_neighbor_cells parameter (four or eight).
CROSS - Connectivity for a region is evaluated between cells of any value, except for the zone cells identified to be excluded by the excluded_value parameter, and subject to the spatial requirements specified by the number_of_neighbor_cells parameter.
add_link
Optional string. Specifies whether a link field will be added to the table of the output when the zone_connectivity parameter is set to WITHIN. It is ignored if that parameter is set to CROSS.
ADD_LINK - A LINK field will be added to the table of the output raster. This field stores the value of the zone to which the cells of each region in the output belong, according to the connectivity rule defined in the number_of_neighbor_cells parameter. This is the default.
NO_LINK - A LINK field will not be added. The attribute table for the output raster will only contain the Value and Count fields.
excluded_value
Optional int. A value that excludes all cells of that zone value from the connectivity evaluation. If a cell location contains the value, no spatial connectivity will be evaluated, regardless of how the number of neighbors is specified.
Cells with the excluded value will be treated in a similar way to NoData cells, and are eliminated from consideration in the operation. Input cells that contain the excluded value will receive 0 on the output raster. The excluded value is similar to the concept of a background value.
If a zone in the input raster has a value of 0, to have that zone be included in the operation, specify a value for this parameter that is not present in the input. For example, if an input raster has values of 0, 1, 2, and 3, specify an excluded_value of 99. Otherwise, all cells of value 0 in the input will be 0 in the output, and will also not have their individual regions determined.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Identify connected regions in an integer raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") input_raster = ImageryLayer("https://myserver/server/rest/services/classified/ImageServer", gis=gis) # Alternatively, create the input layer from a portal item. input_raster = gis.content.search("title:classified", item_type="Imagery Layer")[0].layers[0] region_group_output = region_group( in_raster=input_raster, number_of_neighbor_cells="EIGHT", zone_connectivity="WITHIN", add_link="ADD_LINK", excluded_value=0, ) region_group_item = region_group_output.save("region_group_output")
shrink
- arcgis.raster.functions.gbl.shrink(input_raster: Raster | ImageryLayer, number_of_cells: int, zone_values: list | str)
Shrinks the selected zones by a specified number of cells by replacing them with the value of the cell that is most frequent in its neighborhood. See Shrink function
The specified zone values are considered foreground zones, while the remaining zone values are considered background zones. With this tool, cells in the foreground zones are allowed to be replaced by cells in the background zones.
NoData has the same priority as any valid value to invade areas vacated by shrinking selected values. Therefore, if a selected value is adjacent to NoData, it may become NoData after shrinking.
Parameter
Description
input_raster
Required ImageryLayer or Raster object. Integer raster containing the zones to be shrunk.
number_of_cells
Required int. The number of cells by which to shrink each specified zone. The value must be integer, and can be 1 or greater.
zone_values
Required list or string. The list of zones to shrink. The zone values must be integer, and they can be in any order. The zone values can be specified as a list or as a string. If specified as a string and if it is required to specify multiple zones, use a semicolon (“;”) to separate the zone values.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Shrink selected zones by one cell. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") classified_raster = ImageryLayer("https://myserver/server/rest/services/classified/ImageServer", gis=gis) # Alternatively, create the input layer from a portal item. classified_raster = gis.content.search("title:classified", item_type="Imagery Layer")[0].layers[0] shrink_output = shrink( input_raster=classified_raster, number_of_cells=1, zone_values=[1, 2, 3], ) shrink_item = shrink_output.save("shrink_output")
sink
- arcgis.raster.functions.gbl.sink(input_flow_direction_raster: Raster | ImageryLayer)
Creates a raster layer identifying all sinks or areas of internal drainage.
A sink is a cell or set of spatially connected cells with a flow direction that cannot be assigned one of the eight valid values in a flow direction raster. This can occur when all neighboring cells are higher than the processing cell or when two cells flow into each other, creating a two-cell loop.
The Sink function only supports a D8 input flow direction raster layer. D8 flow directions can be created using the
flow_directionfunction and run with default flow direction type D8.For more information, see Sink function
Parameter
Description
input_flow_direction_raster
Required ImageryLayer or Raster object. D8 flow-direction raster showing the direction of flow out of each cell.
The flow direction raster can be created by running the
flow_directionfunction.- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Identify sinks from a flow direction raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") flow_direction_raster = ImageryLayer("https://myserver/server/rest/services/flow_direction/ImageServer", gis=gis) # Alternatively, create the input layer from a portal item. flow_direction_raster = gis.content.search("title:flow direction", item_type="Imagery Layer")[0].layers[0] sink_output = sink(input_flow_direction_raster=flow_direction_raster) sink_item = sink_output.save("sink_output")
snap_pour_point
- arcgis.raster.functions.gbl.snap_pour_point(in_pour_point_data: Raster | ImageryLayer, in_accumulation_raster: Raster | ImageryLayer | None = None, snap_distance: int = 0, pour_point_field: str | None = None)
Snaps pour points to the cell of highest flow accumulation within a specified distance.
The Snap Pour Point function is used to ensure the selection of points of high accumulated flow when delineating drainage basins using the Watershed function. Snap Pour Point will search within a snap distance around the specified pour points for the cell of highest accumulated flow and move the pour point to that location.
For more information, see Snap Pour Point function
Parameter
Description
in_pour_point_data
Required ImageryLayer or Raster object. The input pour point locations that are to be snapped. For an input raster layer, all cells that are not NoData (that is, have a value) will be considered pour points and will be snapped.
in_accumulation_raster
Optional ImageryLayer or Raster object. The input flow accumulation raster layer. The flow accumulation raster can be created by persisting the output layer generated from
flow_accumulationfunction using the save function.snap_distance
Optional int. Maximum distance, in map units, to search for a cell of higher accumulated flow. Default is 0
pour_point_field
Optional string. Field used to assign values to the pour point locations.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Snap pour points to cells of high flow accumulation. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") pour_point_raster = ImageryLayer("https://myserver/server/rest/services/pour_points/ImageServer", gis=gis) flow_accumulation_raster = ImageryLayer("https://myserver/server/rest/services/flow_accumulation/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. pour_point_raster = gis.content.search("title:pour points", item_type="Imagery Layer")[0].layers[0] flow_accumulation_raster = gis.content.search("title:flow accumulation", item_type="Imagery Layer")[0].layers[0] snap_pour_point_output = snap_pour_point( in_pour_point_data=pour_point_raster, in_accumulation_raster=flow_accumulation_raster, snap_distance=30, pour_point_field="Value", ) snap_pour_point_item = snap_pour_point_output.save("snap_pour_point_output")
stream_link
- arcgis.raster.functions.gbl.stream_link(input_raster: Raster | ImageryLayer, input_flow_direction_raster: Raster | ImageryLayer)
Assigns unique values to sections of a raster linear network between intersections.
Links are the sections of a stream channel connecting two successive junctions, a junction and the outlet, or a junction and the drainage divide. In hydrology, these stream segments are called reaches. A junction is related to a pour point and helps delineate a watershed or drainage sub-basin boundary.
For more information, see Stream Link function
Parameter
Description
input_raster
Required ImageryLayer or Raster object. Raster whose cells represent a linear stream network. The input stream raster can be created by thresholding the results of the
flow_accumulationfunction.input_flow_direction_raster
Required ImageryLayer or Raster object. The input raster that shows the direction of flow out of each cell. The flow direction raster can be created by the results of the
flow_directionfunction.- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Assign unique values to stream sections. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") stream_raster = ImageryLayer("https://myserver/server/rest/services/streams/ImageServer", gis=gis) flow_direction_raster = ImageryLayer("https://myserver/server/rest/services/flow_direction/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. stream_raster = gis.content.search("title:streams", item_type="Imagery Layer")[0].layers[0] flow_direction_raster = gis.content.search("title:flow direction", item_type="Imagery Layer")[0].layers[0] stream_link_output = stream_link( input_raster=stream_raster, input_flow_direction_raster=flow_direction_raster, ) stream_link_item = stream_link_output.save("stream_link_output")
stream_order
- arcgis.raster.functions.gbl.stream_order(input_stream_raster: Raster | ImageryLayer, input_flow_direction_raster: Raster | ImageryLayer | None = None, order_method: str = 'STRAHLER')
Creates a raster layer that assigns a numeric order to segments of a raster representing branches of a linear network.
The output of the Stream Order function will be of higher quality if the input stream raster layer and input flow direction raster layer are derived from the same surface. If the stream raster is derived from a rasterized streams dataset, the output may not be usable because, on a cell-by-cell basis, the direction will not correspond with the location of stream cells.
The results of the Flow Accumulation function can be used to create a raster stream network by applying a threshold value to select cells with a high accumulated flow.
For example, cells that have more than 100 cells flowing into them are used to define the stream network. Use the Con or Set Null function to create a stream network raster where flow accumulation values of 100 or greater go to one, and the remainder are put to the background (NoData). The resulting stream network can be used in the Stream Order function.
This function only supports a D8 input flow direction raster layer. D8 flow directions can be created using the Flow Direction function and run with the default flow direction type D8.
For more information, see Stream Order function
Parameter
Description
input_stream_raster
Required ImageryLayer or Raster object. An input stream raster that represents a linear stream network.
input_flow_direction_raster
Optional ImageryLayer or Raster object. The input raster that shows the direction of flow out of each cell The flow direction raster can be created by persisting the output layer generated from
flow_directionfunction using thesave()method on the ImageryLayer or Raster object.order_method
Optional string. The method used for assigning stream order.
STRAHLER - The method of stream ordering proposed by Strahler in 1952. Stream order only increases when streams of the same order intersect. Therefore, the intersection of a first-order and second-order link will remain a second-order link, rather than creating a third-order link. This is the default.
SHREVE - The method of stream ordering by magnitude, proposed by Shreve in 1967. All links with no tributaries are assigned a magnitude (order) of one. Magnitudes are additive downslope. When two links intersect, their magnitudes are added and assigned to the downslope link.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Assign STRAHLER order to a stream network. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") stream_raster = ImageryLayer("https://myserver/server/rest/services/streams/ImageServer", gis=gis) flow_direction_raster = ImageryLayer("https://myserver/server/rest/services/flow_direction/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. stream_raster = gis.content.search("title:streams", item_type="Imagery Layer")[0].layers[0] flow_direction_raster = gis.content.search("title:flow direction", item_type="Imagery Layer")[0].layers[0] stream_order_output = stream_order( input_stream_raster=stream_raster, input_flow_direction_raster=flow_direction_raster, order_method="STRAHLER", ) stream_order_item = stream_order_output.save("stream_order_output")
viewshed
- arcgis.raster.functions.gbl.viewshed(input_raster: Raster | ImageryLayer, input_observer_features: FeatureLayer, analysis_method: str = 'ALL_SIGHTLINES', analysis_type: str = 'FREQUENCY', vertical_error: str = '0 Meters', refractivity_coefficient: float = 0.13, surface_offset: str = '0 Meters', observer_elevation: str | int | None = None, observer_offset: str = '1 Meters', inner_radius: int | None = None, inner_radius_is_3d: bool = False, outer_radius: int | None = None, outer_radius_is_3d: bool = False, horizontal_start_angle: float = 0, horizontal_end_angle: float = 360, vertical_upper_angle: float = 90, vertical_lower_angle: float = -90)
Determines the raster surface locations visible to a set of observer features using geodesic methods.
- There are two types of visibility analyses that can be performed by this function:
Frequency — determines which raster surface locations are visible to a set of observers.
Observers - identifies which observers are visible from each raster surface location.
For more information, see Viewshed function
Parameter
Description
input_raster
Required ImageryLayer or Raster object. The input surface raster. It can be an integer or a floating-point raster.
The input is transformed into a 3D geocentric coordinate system during the visibility calculation. NoData cells on the input raster do not block the visibility determination.
input_observer_features
Required FeatureLayer. The input feature class that identifies the observer locations. It can be point, multipoint, or polyline features.
The input feature class is transformed into a 3D geocentric coordinate system during the visibility calculation. Observers outside of the extent of the surface raster, or located on NoData cells, will be ignored in the calculation.
analysis_method
Optional string. Choose the method by which the visibility will be calculated. This option allows you to trade some accuracy for increased performance.
ALL_SIGHTLINES - A sightline is performed on every pixel in the raster in order to establish visible areas. This is the default method.
PERIMETER_SIGHTLINES - Sightlines are only performed to the pixels on the perimeter of the visible areas in order to establish visibility areas. This method has a better performance than the ALL_SIGHTLINES method since less sightlines are in the calculation.
analysis_type
Optional string. Choose which type of visibility analysis you wish to perform, either determining how visible each cell is to the observers, or identifying for each surface location which observers are visible.
FREQUENCY - The number of times that each pixel location in the input surface raster can be seen by the input observation locations (as points or as vertices for polyline observer features). This is the default.
OBSERVERS - The output identifies exactly which observer points are visible from each raster surface location. The allowed maximum number of input observers is 32 with this analysis type.
vertical_error
Optional string. The amount of uncertainty, measured as Root Mean Square error (RMSE), in the surface elevation values. It is a floating-point value representing the expected error of the input elevation values. When this parameter is assigned a value greater than 0, the output visibility raster will be floating point. In this case, each pixel value on the output visibility raster represents the sum of probabilities that the cell is visible to any of the observers.
When the Analysis Type is OBSERVERS or the Analysis Method is PERIMETER_SIGHTLINES, this parameter is not honoured.
refractivity_coefficient
Optional float. Coefficient of the refraction of visible light in air.
The default value is 0.13.
surface_offset
Optional string. This value indicates a vertical distance (in surface units) to be added to the z-value of each target pixel as it is considered for visibility. It should be a positive integer or floating-point value.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
observer_elevation
Optional int or string. This value is used to define the surface elevations of the observer points or vertices.
It can be a field in the input input_observer_features or a numerical value. If this parameter is not specified, the observer elevation will be obtained from the surface raster using bilinear interpolation. If this parameter is set to a value, then that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
observer_offset
Optional string. This value indicates a vertical distance (in surface units) to be added to observer elevation. It should be a positive integer or floating-point value.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
inner_radius
Optional int. This value defines the start (minimum) distance from which visibility is determined. Pixels closer than this distance are considered not visible in the output but can still block visibility of the pixels between the inner_radius and the outer_radius. The default value is 0.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
inner_radius_is_3d
Optional bool. Type of distance for the inner radius parameter.
False - Inner Radius is to be interpreted as a 2D distance. This is the default.
True - Inner Radius is to be interpreted as a 3D distance.
outer_radius
Optional int. This value defines the maximum distance from which visibility is determined. Pixels beyond this distance are excluded from the analysis.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
outer_radius_is_3d
Optional bool. Type of distance for the outer_radius parameter.
False - outer_radius is to be interpreted as a 2D distance. This is the default.
True - outer_radius is to be interpreted as a 3D distance.
horizontal_start_angle
Optional float. This value defines the start angle of the horizontal scan range. The value should be specified in degrees from 0 to 360.0, where 0 is oriented to north. The default value is 0.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
horizontal_end_angle
Optional float. This value defines the end angle of the horizontal scan range. The value should be specified in degrees from 0 to 360.0, where 0 is oriented to north. The default value is 360.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
vertical_upper_angle
Optional float. This value defines the upper vertical angle limit of the scan above a horizontal plane. The value should be specified in degrees from 0 to 90.0, which can be integer or floating point. The default value is 90.0.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
vertical_lower_angle
Optional float. This value defines the lower vertical angle limit of the scan below a horizontal plane. The value should be specified in degrees from -90.0 to 0, which can be integer or floating point. The default value is -90.0.
It can be a field in the input_observer_features or a numerical value. If this parameter is set to a value, that value will be applied to all the observers. To specify different values for each observer, set this parameter to a field in the input_observer_features.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Calculate visible areas from observer locations. from arcgis.gis import GIS from arcgis.raster import ImageryLayer from arcgis.features import FeatureLayer gis = GIS("home") surface_raster = ImageryLayer("https://myserver/server/rest/services/elevation/ImageServer", gis=gis) observer_features = FeatureLayer("https://myserver/server/rest/services/observers/FeatureServer/0", gis=gis) # Alternatively, create the input layers from portal items. surface_raster = gis.content.search("title:elevation", item_type="Imagery Layer")[0].layers[0] observer_features = gis.content.search("title:observers", item_type="Feature Layer")[0].layers[0] viewshed_output = viewshed( input_raster=surface_raster, input_observer_features=observer_features, analysis_method="ALL_SIGHTLINES", analysis_type="FREQUENCY", vertical_error="0 Meters", refractivity_coefficient=0.13, surface_offset="0 Meters", observer_offset="1 Meters", ) viewshed_item = viewshed_output.save("viewshed_output")
watershed
- arcgis.raster.functions.gbl.watershed(input_flow_direction_raster: Raster | ImageryLayer, input_pour_point_data: Raster | ImageryLayer, pour_point_field: str | None = None)
Determines the contributing area above a set of cells in a raster. Watersheds are delineated from a flow direction raster which identifies the flow direction from every cell.
You will need to provide the locations from which to determine the catchment area. When a threshold is used to define a watershed, the pour points for the watershed will be the junctions of a stream network derived from flow accumulation. Therefore, a flow accumulation raster must be specified as well as the minimum number of cells that constitute a stream (the threshold value).
The value of each delineated watershed will be taken from the cell value of the pour point in the input raster.
For more information, see Watershed function
Parameter
Description
input_flow_direction_raster
Required ImageryLayer or Raster object. The input raster that shows the direction of flow out of each cell. The flow direction raster can be created by the results of the
flow_directionfunction.input_pour_point_data
Required ImageryLayer or Raster object. The input pour point locations.
This raster represents cells above which the contributing area, or catchment, will be determined. All cells that are not NoData will be used as source cells.
pour_point_field
Optional string. Field used to assign values to the pour point locations. For a raster pour point dataset, Value is used by default.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Determine the contributing area above a set of cells in a raster. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") flow_direction_raster = ImageryLayer("https://myserver/server/rest/services/flow_direction/ImageServer", gis=gis) pour_point_raster = ImageryLayer("https://myserver/server/rest/services/pour_points/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. flow_direction_raster = gis.content.search("title:flow direction", item_type="Imagery Layer")[0].layers[0] pour_point_raster = gis.content.search("title:pour points", item_type="Imagery Layer")[0].layers[0] watershed_output = watershed( input_flow_direction_raster=flow_direction_raster, input_pour_point_data=pour_point_raster, pour_point_field="Value", ) watershed_item = watershed_output.save("watershed_output")
zonal_statistics
- arcgis.raster.functions.gbl.zonal_statistics(in_zone_data: Raster | ImageryLayer, zone_field: str | int, in_value_raster: Raster | ImageryLayer, ignore_nodata: bool = True, statistics_type: str = 'MEAN', process_as_multidimensional: bool | None = None, percentile_value: float = 90, percentile_interpolation_type: str = 'AUTO_DETECT', circular_calculation: bool = False, circular_wrap_value: float = 360)
Calculates statistics on values of a raster within the zones of another dataset.
A zone is defined as all areas in the input that have the same value. These areas do not have to be contiguous. When the zone and value inputs are both rasters of the same resolution, they will be used directly. If the resolutions are different, an internal nearest neighbor resampling is applied to make the resolutions match to that of the coarser input before the zonal operation is performed.
The Zone Raster must be an integer raster input. If you have feature zones, first convert the feature data into a raster with the
convert_raster_to_featurefunction before using it in this function.For more information, see Zonal Statistics function
Parameter
Description
in_zone_data
Required ImageryLayer or Raster object. The zones can be defined by an integer raster.
zone_field
Required string or int. Field that holds the values that define each zone. It can be an integer or a string field of the zone raster.
in_value_raster
Required ImageryLayer or Raster object. Integer or floating-point raster containing values on which to calculate a statistic.
ignore_nodata
Optional bool. Denotes whether NoData values in the Value Raster will influence the results of the zone that they fall within.
True - Within any particular zone, only pixels that have a value in the Value Raster will be used in determining the output value for that zone. NoData pixels in the Value Raster will be ignored in the statistic calculation. This is the default.
False - Within any particular zone, if any NoData pixels exist in the Value Raster, it is deemed that there is insufficient information to perform statistical calculations for all the pixels in that zone; therefore, the entire zone will receive the NoData value on the output raster.
statistics_type
Optional string. Statistic type to be calculated. Default is MEAN
MEAN-Calculates the average of all pixels in the Value Raster that belong to the same zone as the output pixel.
MAJORITY-Determines the value that occurs most often of all pixels in the Value Raster that belong to the same zone as the output pixel.
MAJORITY_COUNT-Calculates the frequency of all cells that contain the majority value in the value raster that belong to the same zone as the output cell.
MAJORITY_PERCENT-Calculates the percentage of cells that contain the majority value in the value raster that belong to the same zone as the output cell.
MAXIMUM-Determines the largest value of all pixels in the Value Raster that belong to the same zone as the output pixel.
MEDIAN-Calculates the median value of all pixels in the Value Raster that belong to the same zone as the output pixel.
MINIMUM-Determines the smallest value of all pixels in the Value Raster that belong to the same zone as the output pixel.
MINORITY-Determines the value that occurs least often of all pixels in the Value Raster that belong to the same zone as the output pixel.
MINORITY_COUNT-Calculates the frequency of all cells that contain the minority value in the value raster that belong to the same zone as the output cell.
MINORITY_PERCENT-Calculates the percentage of cells that contain the minority value in the value raster that belong to the same zone as the output cell.
PERCENTILE-Calculates a percentile of all cells in the value raster that belong to the same zone as the output cell. The 90th percentile is calculated by default. You can specify other values (from 0 to 100) using the percentile_value parameter.
RANGE-Calculates the difference between the largest and smallest value of all pixels in the Value Raster that belong to the same zone as the output pixel.
STD-Calculates the standard deviation of all pixels in the Value Raster that belong to the same zone as the output pixel.
SUM-Calculates the total value of all pixels in the Value Raster that belong to the same zone as the output pixel.
VARIETY-Calculates the number of unique values for all pixels in the Value Raster that belong to the same zone as the output pixel.
process_as_multidimensional
Optional bool. Process as multidimensional if set to True. (If the input is multidimensional raster.)
percentile_value
Optional float. The percentile to calculate. The default is 90, for the 90th percentile. The values can range from 0 to 100. The 0th percentile is essentially equivalent to the Minimum statistic, and the 100th percentile is equivalent to Maximum. A value of 50 will produce essentially the same result as the Median statistic.
This parameter is honoured only if the statistics_type parameter is set to PERCENTILE.
percentile_interpolation_type
Optional string. Specifies the method of interpolation to be used when the specified percentile value lies between two input cell values.
AUTO_DETECT - If the input value raster has integer pixel type, the NEAREST method is used. If the input value raster has floating point pixel type, then the LINEAR method is used. This is the default.
NEAREST - Nearest value to the desired percentile. In this case, the output pixel type is same as that of the input value raster.
LINEAR - Weighted average of two surrounding values from the desired percentile. In this case, the output pixel type is floating point.
Parameter available in ArcGIS Image Server 10.9 and higher.
circular_calculation
Optional bool. Denotes whether the statistics calculations will be arithmetic or circular.
False - Calculates arithmetic statistics. This is the default.
True - Calculates circular statistics that are appropriate for cyclic quantities, such as compass direction in degrees, daytimes, and fractional parts of real numbers.
Parameter available in ArcGIS Image Server 11 and higher.
circular_wrap_value
Optional float. The possible highest value (upper bound) in the cyclic data. It is a positive number, and the default is 360. This value also represents the same quantity as the possible lowest value (lower bound). This parameter is honored only if the circular_calculation parameter is set to True.
Parameter available in ArcGIS Image Server 11 and higher.
- Returns:
Output ImageryLayer/Raster object with the function applied. The returned layer cannot be visualized on the fly. It must be persisted using the
save()method on the ImageryLayer/Raster object.
# Usage Example: Calculate mean cell values for each zone. from arcgis.gis import GIS from arcgis.raster import ImageryLayer gis = GIS("home") zone_raster = ImageryLayer("https://myserver/server/rest/services/zones/ImageServer", gis=gis) value_raster = ImageryLayer("https://myserver/server/rest/services/values/ImageServer", gis=gis) # Alternatively, create the input layers from portal items. zone_raster = gis.content.search("title:zones", item_type="Imagery Layer")[0].layers[0] value_raster = gis.content.search("title:values", item_type="Imagery Layer")[0].layers[0] zonal_statistics_output = zonal_statistics( in_zone_data=zone_raster, zone_field="Value", in_value_raster=value_raster, ignore_nodata=True, statistics_type="MEAN", ) zonal_statistics_item = zonal_statistics_output.save("zonal_statistics_output")