Calculate Distance (Raster Analysis)

Title  Calculate Distance (Raster Analysis)

Summary

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


Illustration

Calculate Distance tool illustration Calculate Distance tool illustration

Usage


Syntax

Parameter Explanation
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.

outputDistanceName

The name of the output distance raster service.

maximumDistance (Optional)

The maximum distance to calculate out to.

The units can be Kilometers, Meters, Miles, Yards, or Feet.

The default units are Meters.

outputCellSize (Optional)

Set the cell size and units for the output raster.

The units can be Kilometers, Meters, Miles, Yards, or Feet.

The default units are Meters.

outputDirectionName (Optional)

The name of the output direction raster service.

outputAllocationName (Optional)

The name of the output allocation raster service.

allocationField (Optional)

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

distanceMethod (Optional)

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

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

Dataset that defines the barriers.

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

outputBackDirectionName (Optional)

The name of the output back direction raster service.

Code Samples

CalculateDistance example 1 (Python window)

This example calculates the Euclidean distance from a single source.


import arcpy
arcpy.CalculateDistance_ra('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.CalculateDistance_ra(inSourceData, outDistanceName, maxDistance, cellSize, outDirectionName,
                           outAllocationName, allocationField)


                    

Tags

Credits

Use limitations