arcgis.raster.functions.gbl module

Global Raster functions. These functions are applied to the raster data to create a processed product on disk, using ImageryLayer.save() method or arcgis.raster.analytics.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 various rasters (or images), including the following:

  • Imagery layers
  • Rasters within imagery layers

cost_allocation

gbl.cost_allocation(in_cost_raster, in_value_raster=None, max_distance=None, source_field=None, source_cost_multiplier=None, source_start_cost=None, source_resistance_rate=None, source_capacity=None, source_direction=None)

Calculates, for each cell, its least-cost source based on the least accumulative cost over a cost surface. For more information, see http://pro.arcgis.com/en/pro-app/help/data/imagery/cost-allocation-global-function.htm

Parameters:
  • in_source_data – The input raster that identifies the pixels or locations to which the least accumulated cost distance for every output pixel location is calculated. The Source Raster can be an integer or a floating-point value. If the input Source Raster is floating point, the Value Raster must be set, and it must be an integer. The Value Raster will take precedence over any setting of the Source Field.
  • in_cost_raster – A raster defining the cost or impedance to move planimetrically through each pixel. The value at each pixel location represents the cost-per-unit distance for moving through it. Each pixel location value is multiplied by the pixel resolution, while also compensating for diagonal movement to obtain the total cost of passing through the pixel. The values of the Cost Raster can be integer or floating point, but they cannot be negative or zero.
  • in_value_raster – The input integer raster that identifies the zone values that should be used for each input source location. For each source location pixel, the value defined by the Value Raster will be assigned to all pixels allocated to the source location for the computation. The Value Raster will take precedence over any setting for the Source Field.
  • max_distance – The threshold that the accumulative cost values cannot exceed. If an accumulative cost distance exceeds this value, the output value for the pixel location will be NoData. The maximum distance defines the extent for which the accumulative cost distances are calculated. The default distance is to the edge of the output raster.
  • source_field – 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_cost_multiplier – This parameter 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 default value is 1. The values must be greater than 0. A numeric (double) value or a field from the Source Raster can be used for this parameter.
  • source_start_cost – The starting cost from which to begin the cost calculations. This parameter allows for the specification of the fixed cost associated with a source. Instead of starting at a cost of 0, the cost algorithm will begin with the value set here. The default is 0. The value must be 0 or greater. A numeric (double) value or a field from the Source Raster can be used for this parameter.
  • source_resistance_rate – This parameter simulates the increase in the effort to overcome costs as the accumulative cost increases. It is used to model fatigue of the traveler. The growing accumulative cost to reach a pixel is multiplied by the resistance rate and added to the cost to move into the subsequent pixel. It is a modified version of a compound interest rate formula that is used to calculate the apparent cost of moving through a pixel. As the value of the resistance rate increases, it increases the cost of the pixels that are visited later. The greater the resistance rate, the higher the cost to reach the next pixel, which is compounded for each subsequent movement. Since the resistance rate is similar to a compound rate and generally the accumulative cost values are very large, small resistance rates are suggested, such as 0.005 or even smaller, depending on the accumulative cost values. The default is 0. The values must be 0 or greater. A numeric (double) value or a field from the Source Raster can be used for this parameter.
  • source_capacity – Defines the cost capacity for the traveler for a source. The cost calculations continue for each source until the specified capacity is reached. The default capacity is to the edge of the output raster. The values must be greater than 0. A double numeric value or a field from the Source Raster can be used for this parameter.
Source_direction:
 

Defines the direction of the traveler when applying the source resistance rate and the source starting cost. FROM_SOURCE - The source resistance rate and source starting cost will be applied beginning at the input source and moving out to the nonsource cells. This is the default. TO_SOURCE - The source resistance rate and source starting cost will be applied beginning at each nonsource cell and moving back to the input source. Either specify the From Source or To Source keyword, which will be applied to all sources, or specify a field in the Source Raster that contains the keywords to identify the direction of travel for each source. That field must contain the string From Source or To Source.

Returns:

output raster with function applied

cost_distance

gbl.cost_distance(in_cost_raster, max_distance=None, source_cost_multiplier=None, source_start_cost=None, source_resistance_rate=None, source_capacity=None, source_direction=None)

Calculates the least accumulative cost distance for each cell from or to the least-cost source over a cost surface. For more information, see http://pro.arcgis.com/en/pro-app/help/data/imagery/cost-distance-global-function.htm

Parameters:
  • in_source_data – The input raster that identifies the pixels or locations to which the least accumulated cost distance for every output pixel location is calculated. The Source Raster can be an integer or a floating-point value.
  • in_cost_raster – A raster defining the cost or impedance to move planimetrically through each pixel. The value at each pixel location represents the cost-per-unit distance for moving through it. Each pixel location value is multiplied by the pixel resolution, while also compensating for diagonal movement to obtain the total cost of passing through the pixel.
  • max_distance – The threshold that the accumulative cost values cannot exceed. If an accumulative cost distance exceeds this value, the output value for the pixel location will be NoData. The maximum distance defines the extent for which the accumulative cost distances are calculated. The default distance is to the edge of the output raster.
  • source_cost_multiplier – The threshold that the accumulative cost values cannot exceed. If an accumulative cost distance exceeds this value, the output value for the pixel location will be NoData. The maximum distance defines the extent for which the accumulative cost distances are calculated. The default distance is to the edge of the output raster.
  • source_start_cost – The starting cost from which to begin the cost calculations. This parameter allows for the specification of the fixed cost associated with a source. Instead of starting at a cost of 0, the cost algorithm will begin with the value set here. The default is 0. The value must be 0 or greater. A numeric (double) value or a field from the Source Raster can be used for this parameter.
  • source_resistance_rate – This parameter simulates the increase in the effort to overcome costs as the accumulative cost increases. It is used to model fatigue of the traveler. The growing accumulative cost to reach a pixel is multiplied by the resistance rate and added to the cost to move into the subsequent pixel. It is a modified version of a compound interest rate formula that is used to calculate the apparent cost of moving through a pixel. As the value of the resistance rate increases, it increases the cost of the pixels that are visited later. The greater the resistance rate, the higher the cost to reach the next pixel, which is compounded for each subsequent movement. Since the resistance rate is similar to a compound rate and generally the accumulative cost values are very large, small resistance rates are suggested, such as 0.005 or even smaller, depending on the accumulative cost values. The default is 0. The values must be 0 or greater. A numeric (double) value or a field from the Source Raster can be used for this parameter.
  • source_capacity – Defines the cost capacity for the traveler for a source. The cost calculations continue for each source until the specified capacity is reached. The default capacity is to the edge of the output raster. The values must be greater than 0. A double numeric value or a field from the Source Raster can be used for this parameter.
  • source_direction – Defines the direction of the traveler when applying the source resistance rate and the source starting cost. FROM_SOURCE - The source resistance rate and source starting cost will be applied beginning at the input source and moving out to the nonsource cells. This is the default. TO_SOURCE - The source resistance rate and source starting cost will be applied beginning at each nonsource cell and moving back to the input source. Either specify the From Source or To Source keyword, which will be applied to all sources, or specify a field in the Source Raster that contains the keywords to identify the direction of travel for each source. That field must contain the string From Source or To Source.
Returns:

output raster with function applied

euclidean_allocation

gbl.euclidean_allocation(in_value_raster=None, max_distance=None, cell_size=None, source_field=None)

Calculates, for each cell, the nearest source based on Euclidean distance. For more information, see http://pro.arcgis.com/en/pro-app/help/data/imagery/euclidean-allocation-global-function.htm

Parameters:
  • in_source_data – raster; The input raster that identifies the pixels or locations to which the Euclidean distance for every output pixel location is calculated. The input type can be an integer or a floating-point value. If the input Source Raster is floating point, the Value Raster must be set, and it must be an integer. The Value Raster will take precedence over any setting of the Source Field.
  • in_value_raster – The input integer raster that identifies the zone values that should be used for each input source location. For each source location pixel, the value defined by the Value Raster will be assigned to all pixels allocated to the source location for the computation. The Value Raster will take precedence over any setting for the Source Field .
  • max_distance – The threshold that the accumulative distance values cannot exceed. If an accumulative Euclidean distance exceeds this value, the output value for the pixel location will be NoData. The default distance is to the edge of the output raster
  • cell_size – The pixel size at which the output raster will be created. If the cell size was explicitly set in Environments, that will be the default cell size. If Environments was not set, the output cell size will be the same as the Source Raster
  • source_field – 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.
Returns:

output raster with function applied

euclidean_distance

gbl.euclidean_distance(cell_size=None, max_distance=None)

Calculates, for each cell, the Euclidean distance to the closest source. For more information, see http://pro.arcgis.com/en/pro-app/help/data/imagery/euclidean-distance-global-function.htm

Parameters:
  • in_source_data – raster; The input raster that identifies the pixels or locations to which the Euclidean distance for every output pixel location is calculated. The input type can be an integer or a floating-point value.
  • cell_size – The pixel size at which the output raster will be created. If the cell size was explicitly set in Environments, that will be the default cell size. If Environments was not set, the output cell size will be the same as the Source Raster
  • max_distance – The threshold that the accumulative distance values cannot exceed. If an accumulative Euclidean distance exceeds this value, the output value for the pixel location will be NoData. The default distance is to the edge of the output raster
Returns:

output raster with function applied

fill

gbl.fill(zlimit=None)

Fills sinks in a surface raster to remove small imperfections in the data

Parameters:
  • input_surface_raster – The input raster representing a continuous surface.
  • zlimit – Data type - Double. 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 raster with function applied

flow_accumulation

gbl.flow_accumulation(input_weight_raster=None, data_type='FLOAT')

” Replaces cells of a raster corresponding to a mask with the values of the nearest neighbors.

Parameters:
  • input_flow_direction_raster – The input raster that shows the direction of flow out of each cell.
  • input_weight_raster – An optional input raster for applying a weight to each cell.
  • data_type – INTEGER, FLOAT, DOUBLE
Returns:

output raster with function applied

flow_distance

gbl.flow_distance(input_surface_raster, input_flow_direction_raster=None, distance_type='VERTICAL')

This function computes, for each cell, the minimum downslope horizontal or vertical distance to cell(s) on a stream or river into which they flow. 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.

Parameters:
  • input_stream_raster – An input raster that represents a linear stream network
  • input_surface_raster – The input raster representing a continuous surface.
  • input_flow_direction_raster – The input raster that shows the direction of flow out of each cell.
  • distance_type – VERTICAL or HORIZONTAL distance to compute; if not specified, VERTICAL distance is computed.
Returns:

output raster with function applied

flow_direction

gbl.flow_direction(force_flow='NORMAL', flow_direction_type='D8', generate_out_drop_raster=False)

Replaces cells of a raster corresponding to a mask with the values of the nearest neighbors.

Parameters:
  • input_surface_raster – The input raster representing a continuous surface.
  • force_flow – NORMAL or FORCE, Specifies if edge cells will always flow outward or follow normal flow rules.
  • flow_direction_type – Specifies which flow direction type to use. D8 - Use the D8 method. This is the default. MFD - Use the Multi Flow Direction (MFD) method. DINF - Use the D-Infinity method.
: param generate_out_drop_raster: Boolean, 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. eg, flow_direction_output = flow_direction(input_surface_raster,

force_flow= “NORMAL”, flow_direction_type= “D8”, generate_out_drop_raster=True)

out_var = flow_direction_output.save() then, 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

Returns:output raster with function applied

least_cost_path

gbl.least_cost_path(in_cost_raster, in_destination_data, destination_field=None, path_type='EACH_CELL', max_distance=None, source_cost_multiplier=None, source_start_cost=None, source_resistance_rate=None, source_capacity=None, source_direction=None)

Calculates the least-cost path from a source to a destination. The least accumulative cost distance is calculated for each pixel over a cost surface, to the nearest source. This produces an output raster that records the least-cost path, or paths, from selected locations to the closest source pixels defined within the accumulative cost surface, in terms of cost distance. For more information, see http://pro.arcgis.com/en/pro-app/help/data/imagery/least-cost-path-global-function.htm

Parameters:
  • in_source_data – The input raster that identifies the pixels or locations to which the least accumulated cost distance for every output pixel location is calculated. The Source Raster can be an integer or a floating-point value. If the input Source Raster is floating point, the Value Raster must be set, and it must be an integer. The Value Raster will take precedence over any setting of the Source Field.
  • in_cost_raster – A raster defining the cost or impedance to move planimetrically through each pixel. The value at each pixel location represents the cost-per-unit distance for moving through it. Each pixel location value is multiplied by the pixel resolution, while also compensating for diagonal movement to obtain the total cost of passing through the pixel. The values of the Cost Raster can be integer or floating point, but they cannot be negative or zero.
  • in_destination_data – A raster dataset that identifies the pixels from which the least-cost path is determined to the least costly source. This input consists of pixels that have valid values, and the remaining pixels must be assigned NoData. Values of 0 are valid.
  • destination_field – The field used to obtain values for the destination locations.
  • path_type – 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_CELL-A least-cost path is determined for each pixel with valid values on the input destination data, and saved on the output raster. Each cell of the input destination data is treated separately, and a least-cost path is determined for each from cell. EACH_ZONE-A least-cost path is determined for each zone on the input destination data and saved on the output raster. The least-cost path for each zone begins at the pixel with the lowest cost distance weighting in the zone. BEST_SINGLE-For all pixels on the input destination data, the least-cost path is derived from the pixel with the minimum of the least-cost paths to source cells.
  • max_distance – The threshold that the accumulative cost values cannot exceed. If an accumulative cost distance exceeds this value, the output value for the pixel location will be NoData. The maximum distance defines the extent for which the accumulative cost distances are calculated. The default distance is to the edge of the output raster.
  • source_field – 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_cost_multiplier – The threshold that the accumulative cost values cannot exceed. If an accumulative cost distance exceeds this value, the output value for the pixel location will be NoData. The maximum distance defines the extent for which the accumulative cost distances are calculated. The default distance is to the edge of the output raster.
  • source_start_cost – The starting cost from which to begin the cost calculations. This parameter allows for the specification of the fixed cost associated with a source. Instead of starting at a cost of 0, the cost algorithm will begin with the value set here. The default is 0. The value must be 0 or greater. A numeric (double) value or a field from the Source Raster can be used for this parameter.
  • source_resistance_rate – This parameter simulates the increase in the effort to overcome costs as the accumulative cost increases. It is used to model fatigue of the traveler. The growing accumulative cost to reach a pixel is multiplied by the resistance rate and added to the cost to move into the subsequent pixel. It is a modified version of a compound interest rate formula that is used to calculate the apparent cost of moving through a pixel. As the value of the resistance rate increases, it increases the cost of the pixels that are visited later. The greater the resistance rate, the higher the cost to reach the next pixel, which is compounded for each subsequent movement. Since the resistance rate is similar to a compound rate and generally the accumulative cost values are very large, small resistance rates are suggested, such as 0.005 or even smaller, depending on the accumulative cost values. The default is 0. The values must be 0 or greater. A numeric (double) value or a field from the Source Raster can be used for this parameter.
  • source_capacity – Defines the cost capacity for the traveler for a source. The cost calculations continue for each source until the specified capacity is reached. The default capacity is to the edge of the output raster. The values must be greater than 0. A double numeric value or a field from the Source Raster can be used for this parameter.
  • source_direction – Defines the direction of the traveler when applying the source resistance rate and the source starting cost. FROM_SOURCE - The source resistance rate and source starting cost will be applied beginning at the input source and moving out to the nonsource cells. This is the default. TO_SOURCE-The source resistance rate and source starting cost will be applied beginning at each nonsource cell and moving back to the input source. Either specify the From Source or To Source keyword, which will be applied to all sources, or specify a field in the Source Raster that contains the keywords to identify the direction of travel for each source. That field must contain the string From Source or To Source.
Returns:

output raster with function applied

nibble

gbl.nibble(input_mask_raster, nibble_values='ALL_VALUES', nibble_no_data='PRESERVE_NODATA', input_zone_raster=None)

Replaces cells of a raster corresponding to a mask with the values of the nearest neighbors.

Parameters:
  • input_raster – The input rater to nibble. The input raster can be either integer or floating point type.
  • input_mask_raster – The input raster to use as the mask.
  • nibble_values – possbile options are “ALL_VALUES” and “DATA_ONLY”. Default is “ALL_VALUES”
  • nibble_no_data – PRESERVE_NODATA or PROCESS_NODATA possible values; Default is PRESERVE_NODATA.
  • input_zone_raster – The input raster that defines the zones to use as the mask.
Returns:

output raster with function applied

watershed

gbl.watershed(input_pour_point_data, pour_point_field=None)

Replaces cells of a raster corresponding to a mask with the values of the nearest neighbors.

Parameters:
  • input_flow_direction_raster – The input raster that shows the direction of flow out of each cell.
  • input_pour_point_data – The input pour point locations. For a raster, this represents cells above which the contributing area, or catchment, will be determined. All cells that are not NoData will be used as source cells. For a point feature dataset, this represents locations above which the contributing area, or catchment, will be determined.
  • pour_point_field – Field used to assign values to the pour point locations. If the pour point dataset is a raster, use Value. If the pour point dataset is a feature, use a numeric field. If the field contains floating-point values, they will be truncated into integers.
Returns:

output raster with function applied

zonal_statistics

gbl.zonal_statistics(zone_field, in_value_raster, ignore_nodata=True, statistics_type=None)

” Calculates statistics on values of a raster within the zones of another dataset. For more information, http://pro.arcgis.com/en/pro-app/help/data/imagery/zonal-statistics-global-function.htm

Parameters:
  • in_zone_data – Dataset that defines the zones. The zones can be defined by an integer raster
  • zone_field – 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 – Raster that contains the values on which to calculate a statistic.
  • ignore_no_data – 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 – Statistic type to be calculated. 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. MAXIMUM-Determines the largest value of all pixels in the Value Raster that belong to the same zone as the output pixel. MEDIAN-Determines 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. 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 Rasterthat 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.
Returns:

output raster with function applied