Calculate Distance (Raster Analysis)

Summary

Calculates the Euclidean distance from a single source or set of sources.

Legacy:

This tool is deprecated and will be removed in a future release.

The Distance Accumulation or Distance Allocation tools provide enhanced functionality or performance.

Illustration

Calculate Distance tool illustration

Usage

  • This raster analysis portal tool is available when you are signed in to an ArcGIS Enterprise portal that has ArcGIS Image Server configured for Raster Analysis. When the tool is run, ArcGIS Pro serves as a client and the processing occurs in the servers federated with ArcGIS Enterprise. The portal tool accepts layers from your portal as input and creates output in your portal.

    The input raster layer supports a layer from the portal, a URI or URL to an image service, or the output from the Make Image Server Layer tool. The input feature layer can be a layer from the portal or a URI or URL to a feature service. This tool does not support local raster data or layers. While you can use local feature data and layers as input to this portal tool, best practice is to use layers from your portal as input.

  • One example application of this tool is finding the distance from any location to the closest town.

  • When the input source data is an image service, the set of source cells consists of all cells in the source raster that have valid values. Cells that have NoData values are not included in the source set. The value 0 is considered a legitimate source.

  • When the input source data is a feature service, the source locations are converted internally to a raster before performing the analysis. The resolution of the raster can be controlled with the Output cell size parameter or the Cell Size environment. By default, the resolution will be determined by the shorter of the width or height of the extent of input feature, in the input spatial reference, divided by 250.

Parameters

LabelExplanationData Type
Input Source Raster or Features

The layer that defines the sources to calculate the distance to. The layer can be image service or feature service.

For image service, the input type can be integer or floating point.

For feature service, the input can be point, line or polygon.

Raster Layer; Image Service; Feature Layer; String
Output Distance Name

The name of the output distance raster service.

String
Maximum Distance
(Optional)

The maximum distance to calculate out to.

The unit values are Kilometers, Meters, Statute Miles, International Yards, International Feet, US Survey Miles, US Survey Yards, and US Survey Feet.

The default units are meters.

Linear Unit
Output Cell Size
(Optional)

Set the cell size and units for the output raster.

The unit values are Kilometers, Meters, Statute Miles, International Yards, International Feet, US Survey Miles, US Survey Yards, and US Survey Feet.

The default units are meters.

Linear Unit
Output Direction Name
(Optional)

The name of the output direction raster service.

String
Output Allocation Name
(Optional)

The name of the output allocation raster service.

String
Allocation Field
(Optional)

A field on the source input that holds the values that define each source. It must be of type integer.

String
Distance Method
(Optional)

Specifies whether to calculate the distance using a planar (flat earth) or a geodesic (ellipsoid) method.

  • PlanarThe distance calculation will be performed on a projected flat plane using a 2D Cartesian coordinate system. This is the default.
  • GeodesicThe distance calculation will be performed on the ellipsoid. Therefore, regardless of input or output projection, the results do not change.
String
Input Barrier Raster or Features
(Optional)

Dataset that defines the barriers.

The barriers can be defined by an integer or floating point raster, or a feature layer.

Raster Layer; Image Service; Feature Layer; String
Output Back Direction Name
(Optional)

The name of the output back direction raster service.

String

Derived Output

LabelExplanationData Type
Output Distance Raster

The output distance raster.

Raster Layer
Output Direction Raster

The output direction raster.

Raster Layer
Output Back Direction Raster

The output back direction raster.

Raster Layer
Output Allocation Raster

The output allocation raster.

Raster Layer

arcpy.ra.CalculateDistance(inputSourceRasterOrFeatures, outputDistanceName, {maximumDistance}, {outputCellSize}, {outputDirectionName}, {outputAllocationName}, {allocationField}, {distanceMethod}, {inputBarrierRasterOrFeatures}, {outputBackDirectionName})
NameExplanationData Type
inputSourceRasterOrFeatures

The layer that defines the sources to calculate the distance to. The layer can be image service or feature service.

For image service, the input type can be integer or floating point.

For feature service, the input can be point, line or polygon.

Raster Layer; Image Service; Feature Layer; String
outputDistanceName

The name of the output distance raster service.

String
maximumDistance
(Optional)

The maximum distance to calculate out to.

The unit values are Kilometers, Meters, MilesInt, YardsInt, FeetInt, Miles, Yards, and Feet.

The default units are meters.

Linear Unit
outputCellSize
(Optional)

Set the cell size and units for the output raster.

The unit values are Kilometers, Meters, MilesInt, YardsInt, FeetInt, Miles, Yards, and Feet.

The default units are meters.

Linear Unit
outputDirectionName
(Optional)

The name of the output direction raster service.

String
outputAllocationName
(Optional)

The name of the output allocation raster service.

String
allocationField
(Optional)

A field on the source input that holds the values that define each source. It must be of type integer.

String
distanceMethod
(Optional)

Specifies whether to calculate the distance using a planar (flat earth) or a geodesic (ellipsoid) method.

  • PlanarThe distance calculation will be performed on a projected flat plane using a 2D Cartesian coordinate system. This is the default.
  • GeodesicThe distance calculation will be performed on the ellipsoid. Therefore, regardless of input or output projection, the results do not change.
String
inputBarrierRasterOrFeatures
(Optional)

Dataset that defines the barriers.

The barriers can be defined by an integer or floating point raster, or a feature layer.

Raster Layer; Image Service; Feature Layer; String
outputBackDirectionName
(Optional)

The name of the output back direction raster service.

String

Derived Output

NameExplanationData Type
outputDistanceRaster

The output distance raster.

Raster Layer
outputDirectionRaster

The output direction raster.

Raster Layer
outputBackDirectionRaster

The output back direction raster.

Raster Layer
outputAllocationRaster

The output allocation raster.

Raster Layer

Code sample

CalculateDistance example 1 (Python window)

This example calculates the Euclidean distance from a single source.

import arcpy
arcpy.ra.CalculateDistance('https://MyPortal.esri.com/server/rest/services/Hosted/myPoints/FeatureServer/0',
                           "outDistance", "5000", "10", "outDirection", "outAllocation", "siting")
CalculateDistance example 2 (stand-alone script)

This example calculates the Euclidean distance from a set of sources.

# Name: CalculateDistance_Ex_02.py
# Description: Calculates for each cell the Euclidean distance, direction and allocation
#              to the nearest source.
# Requirements: ArcGIS Image Server

# Import system modules
import arcpy

# Set local variables
inSourceData = 'https://MyPortal.esri.com/server/rest/services/Hosted/reccenter/ImageServer'
outDistanceName = "eucdistance"
maxDistance = "4000"
cellSize = "10"
outDirectionName = "eucdirect"
outAllocationName = "eurallocation"
allocationField = "dataid"


# Execute EucDistance
arcpy.ra.CalculateDistance(inSourceData, outDistanceName, maxDistance, cellSize, outDirectionName,
                           outAllocationName, allocationField)

Licensing information

  • Basic: Requires ArcGIS Image Server
  • Standard: Requires ArcGIS Image Server
  • Advanced: Requires ArcGIS Image Server

Related topics