Calculate Distance

Available in real-time and big data analytics.

The Calculate Distance tool can calculate the distance from a target feature to the nearest feature in the same feed or in another feed or dataset. Candidate nearest features can be limited based on an attribute relationship between the target and near features.

Examples

The following are example uses of the Calculate Distance tool:

  • An emergency operations manager is monitoring field crew locations in real time. Each time a worker's location is updated, a real-time analytic calculates the distance from the worker's active position to their assigned base of operations.
  • Calculating the distance from an incoming feed of emergency events to a different feed of emergency response vehicles moving in the same vicinity to determine the closest responder to the event.
  • Calculating the distance from the features in a shipping vessel feed to other features in the same feed to determine whether any are in dangerous proximity to one another.

Usage notes

Keep the following in mind when working with the Calculate Distance tool:

  • For every target feature, the distance is calculated to the nearest feature in the join layer within the provided search radius. The performance is affected by the number of features in the search radius.
  • If the Keep outside distance features parameter is set to No, the output contains only those target features for which a join feature is found in the search radius and satisfies the attribute relationship, if specified. If set to Yes, the output contains all target features. If there is not a join feature found for a target feature in the specified search radius, the DistanceToFeature output value is null.
  • The Spatial Relationship parameter can be set to Near geodesic or Near planar.
    • Near geodesic calculates geodesic distance. This accounts for the actual shape of the earth (an ellipsoid, or more properly, a geoid). Distances are calculated between two points on a curved surface (the geoid) as opposed to two points on a flat surface (the Cartesian plane). Always consider calculating geodesic distance in the following circumstances:
      • The input features are dispersed (cover multiple coordinated universal time (UTM) zones, large regions, or the entire globe).
      • The spatial reference (map projection) of the input features distorts distances to preserve other properties such as area.
    • Near planar calculates Euclidean distance. This is the distance in a two-dimensional Cartesian plane in which straight-line or Euclidean distances are calculated between two points on a flat surface (the Cartesian plane). This is useful when analyzing distances between features that are concentrated in a relatively small area, such as one UTM zone.
    • If a feed is connected to the join port, distance calculations are performed dynamically based on the changing features in both the target and join feeds.
    • In dynamic geofencing, the Join Time Window parameter must be set. If the join feed does not have a field tagged as END_TIME and the last known observation for a join feature is older than this window, the join feed is deleted from the tool's memory and is not included in the analysis. If the join feed has a field tagged as END_TIME, the feature ages out of the geofence store according to the value in the field tagged as END_TIME or when the join time window is closed, whichever comes first. Restarting a real-time analytic does not cause features to expire from the geofence store.
  • An attribute relationship can be specified to measure distance from a target feature to the nearest feature in another dataset with a matching attribute value.
  • One or more fields can be specified from the near (join) feature to join with the target feature.

Parameters

The following are the parameters for the Calculate Distance tool:

ParameterDescriptionData type

Target Layer

The features that the Calculate Distance tool process.

Features

Join Layer

The layer in which to identify the nearest feature for each feature in the Target Layer parameter and calculate the distance between them.

Features

Spatial Relationship

The method used to create the search radius for finding nearest features.

Spatial operators include Near geodesic or Near planar.

Note:

Keep the following in mind:

  • If Near planar is selected, the target features and nearest features must both be projected. The Project tool can be used to project the input points prior to running the Calculate Distance tool.
  • The Near geodesic spatial search method is only supported when both the target and near (join) features are point features.

String

Spatial Search Radius

The distance within which to identify the nearest feature. Features outside this distance are not considered.

Linear Unit

Attribute Relationship (optional)

Limits the candidate nearest features based on a relationship between the target and near (join) features. Specify which attribute field from the target layer matches an attribute field from the near (join) layer.

String

Output Distance Units

The output distance units for the distance calculation.

String

Join Fields (optional)

A set of fields from the near (join) features to join to the target features.

String

Join Time Window

The time window for the join feed (dynamic geofencing). If the last known observation for a join feature is older than the time window specified, it is deleted and is not included in the analysis. If the join feed has a field marked as END_TIME, this parameter is optional.

String

Keep outside distance features

Specifies whether to output all target features or only those for which a join feature was found within the search radius and satisfies the attribute relationship, if specified.

Boolean

Output layer

The output layer is appended with the new DistanceToFeature field name. Additionally, any fields specified in the Join Fields parameter are also appended to the output layer.

Field nameDescriptionField type

DistanceToFeature

The distance from the feature to the nearest feature in Join Layer in the units defined in the Output distance units parameter.

Float64

Consideration and limitation

Consider the following when working with the Calculate Distance tool:

The Near geodesic spatial search method is only supported as the spatial relationship when both the target and near (join) features are point features.