Skip To Content
ArcGIS Developer
Dashboard

Join Features

Description

Join Features

The JoinFeatures operation works with two layers. JoinFeatures joins attributes from one feature to another based on spatial, temporal, and attribute relationships or a combination of the three. The tool determines all input features that meet the specified join conditions and joins the second input layer to the first. You can join all features to the matching features or summarize the matching features.

JoinFeatures can be applied to points, lines, polygons, and tables.

Request parameters

ParameterDetails
targetLayer

(Required)

The table, point, line, or polygon features to which the joinLayer features will be joined.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST examples

//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

//REST scripting example
"targetLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}
joinLayer

(Required)

The point, line, or polygon features that will be joined to the targetLayer features.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST examples

//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/areaOfInterest/FeaturesServer/0", "filter": "length > 10"}

//REST scripting example
"joinLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/areaOfInterest/FeatureServer/0", "filter": "Length > 10"}
joinOperation

(Required)

A string representing the type of join that will be applied. There are two options available: JoinOneToOne and JoinOneToMany.

For JoinOneToOne, if multiple join features are found that have the same relationship with a single target feature, the attributes from the multiple join features will be aggregated using the specified summary statistics. For example, if a point feature is found within two separate polygon join features, the attributes from the two polygons will be aggregated before being transferred to the output point feature class. If one polygon has an attribute value of 3 and the other has a value of 7, and a summaryField value of sum is specified, the aggregated value in the output feature class will be 10. There will always be a Count field calculated, with a value of 2, for the number of features specified.

For JoinOneToMany, if multiple join features are found that have the same relationship with a single target feature, the output feature class will contain multiple copies (records) of the target feature. For example, if a single point target feature is found within two separate polygon join features, the output feature class will contain two copies of the target feature: one record with the attributes of the first polygon, and another record with the attributes of the second polygon. No summary statistics are calculated with this method.

REST examples

//REST web example
JoinOneToMany

//REST scripting example
"joinOperation": "JoinOneToOne"
keepAllTargetFeatures

(Optional)

Specifies whether all target features will be maintained in the output feature class (known as a left outer join) or only those that have the specified relationships with the join features (inner join). This parameter is only available when the joinOperation parameter value is JoinOneToOne. The default value is false (inner join).

This parameter is available at ArcGIS GeoAnalytics Server 10.9 or later.

REST examples

//REST web example
true

//REST scripting example
"keepAllTargetFeatures":false
joinFields

(Required)

A list of modifications to field names in the joinLayer value to be made before completing analysis. Any field that is removed will not have statistics calculated on it.

In the syntax below, action can be either remove or rename. remove specifies that a field will be removed from analysis and output. rename specifies that a field will be renamed before running the analysis.

REST examples

//REST web example
[{"action": "rename", "field": "ZipCode", "to": "Zip"},{"action": "remove", "field": "fieldname1"}]

//REST scripting example
"joinFields": [{"action": "rename", "field": "ZipCode", "to": "Zip"},{"action": "remove", "field": "fieldname1"}]
summaryFields

(Optional)

A list of field names and statistical summary types you want to calculate. Note that the count is always returned. By default, all statistics are returned.

onStatisticField specifies the name of the fields in the target layer. statisticType is one of the following for numeric fields:

  • Count—For numeric fields, this totals the number of values of all the points in each polygon. For string fields, this totals the number of strings for all the points in each polygon.
  • Sum—Adds the total value of all the points in each polygon. This is for numeric fields.
  • Mean—Calculates the average of all the points in each polygon. This is for numeric fields.
  • Max—Calculates the largest value of all the points in each polygon. This is for numeric fields.
  • Range—Finds the difference between the Min and Max values. This is for numeric fields.
  • Stddev—Finds the standard deviation of all the points in each polygon. This is for numeric fields.
  • Var—Finds the variance of all the points in each polygon. This is for numeric fields.
  • Any—Returns a sample string of a point in each polygon. This is for string fields.

REST examples

//REST web examples
[{"statisticType": "Mean", "onStatisticField": "Annual_Sales"},{"statisticType": "Sum", "onStatisticField": "Annual_Sales"}]

//REST scripting example
"summaryFields": ["statisticType": "Mean", "onStatisticField": "Annual_Sales"},{"statisticType": "Sum", "onStatisticField": "Annual_Sales"}]

//Only return Count
"summaryFields": []
spatialRelationship

(Required)

Specifies the spatial relationship used to spatially join features. To learn more about the supported spatial relationships, see Spatial relationships in ArcGIS GeoAnalytics Server.

Values: Equals | Intersects | Contains | Within | Crosses | Touches | Overlaps | Near | NearGeodesic (at 10.7.1 or later)

REST examples

//REST web examples
Intersects

//REST scripting examples
"spatialRelationship": "Intersects"
spatialNearDistance

(Required if spatialRelationship is Near or NearGeodesic)

A double value used for the search distance to determine if the targetFeatures value are near the joinFeatures value. This is only applied if Near or NearGeodesic is the selected spatialRelationship value. You can enter a single distance value. The units of the distance values are supplied by the spatialNearDistanceUnit parameter.

Analysis using a Near spatial relationship requires that the targetLayer or processing extent (processSR) have a projected coordinate system.

REST examples

//REST web example
4

//REST scripting example
"spatialNearDistance": 4
spatialNearDistanceUnit

(Required if spatialRelationship is Near or NearGeodesic)

The linear unit to be used with the distance value specified in spatialNearDistance. The default value is Meters.

Values: Meters | Kilometers | Feet | FeetInt | FeetUS | Miles | MilesInt | MilesUS | NauticalMiles | NauticalMilesInt | NauticalMilesUS | Yards | YardsInt | YardsUS

REST examples

//REST web example
Miles

//REST scripting example
"spatialNearDistanceUnit": "Miles"
temporalRelationship

(Optional)

Specifies the temporal relationship used to temporally join features.

Values: Equals | Intersects | During | Contains | Finishes | FinishedBy | Meets | MetBy | Overlaps | OverlappedBy | Starts | StartedBy | Near | NearBefore | NearAfter

REST examples

//REST web example
Near

//REST scripting example
"temporalRelationship": "Intersects"
temporalNearDistance

(Required if temporalRelationship is Near, NearBefore, or NearAfter)

An integer value used for the temporal search distance to determine if the targetFeatures values are temporally near the joinFeatures values. This is only applied if Near, NearBefore, or NearAfter is specified for temporalRelationship. You can only enter a single distance value. The units of the distance values are supplied by the temporalNearDistanceUnit parameter.

REST examples

//REST web example
4

//REST scripting example
"temporalNearDistance": 53
temporalNearDistanceUnit

(Required if temporalRelationship is Near, NearBefore, or NearAfter)

The temporal unit to be used with the distance value specified in temporalNearDistance.

Values: Meters | Kilometers | Feet | FeetInt | FeetUS | Miles | MilesInt | MilesUS | NauticalMiles | NauticalMilesInt | NauticalMilesUS | Yards | YardsInt | YardsUS

REST examples

//REST web example
Minutes

//REST scripting example
"temporalNearDistanceUnit": "Minutes"
includeDistance

(Optional)

This parameter is available at ArcGIS GeoAnalytics Server 11.2 or later.

Specifies whether or not to include the spatial distance and/or temporal difference calculated between target and join features when joinOperation is JoinOneToMany. The spatial distance between target and join features will be included in the result when spatialRelationship is Near or NearGeodesic. The temporal difference (or time gap) between target and join features will be included in the result when temporalRelationship is Near, NearBefore, or NearAfter. The default is false.

REST examples

//REST web example
true

//REST scripting example
"includeDistance": true
distanceUnit

(Optional)

This parameter is available at ArcGIS GeoAnalytics Server 11.2 or later.

Specifies the unit of measure that will be used for distance values in the result. The default is Meters.

Values: Meters | Kilometers | Feet | FeetInt | FeetUS | Miles | MilesInt | MilesUS | NauticalMiles | NauticalMilesInt | NauticalMilesUS | Yards | YardsInt | YardsUS

REST examples

//REST web example
Kilometers

//REST scripting example
"distanceUnit": "Kilometers"
attributeRelationship

(Optional)

A target field, relationship, and join field used to join equal attributes. You can join strings that are equal without comparing casing or trailing and leading spaces using equalIgnoreCaseTrimeWhiteSpace through JSON or ~= using a string.

REST examples


//REST JSON web example
[{  
  "targetField": "ZipArea",  
  "joinField": "ZipCode",  
  "operator": "equal"
}]

//REST string web example
target.ZipArea = join.ZipCode

//REST JSON scripting example
"attributeRelationship": [{  
  "targetField": "ZipArea",  
  "joinField": "ZipCode",  
  "operator": "equalIgnoreCaseTrimWhitespace"
}]

//REST string scripting example
"attributeRelationship": "target.ZipArea ~= join.ZipCode"
joinCondition

(Optional)

Applies a condition to specified fields. Only features with fields that meet these conditions will be joined. This should always be used with a spatial, temporal, or field attribute relationship, or a combination of the three.

For example, to apply a join to a dataset for only those features in which health_spending is greater than 20 percent of income, and apply a join condition of $target['health_spending'] > ($join['income'] * .20) using the health_spending field from the first dataset (targerLayer) and the income field from the second dataset (joinLayer), use the following:

REST examples

//REST web example
$target['health_spending'] == ($join['income'] * .20)

//REST scripting example
"joinCondition": "$target['health_spending'] == ($join['income'] * .20)"
outputName

(Required)

The task will create a feature service of the results. You define the name of the service.

REST examples

//REST web example
myOutput

//REST scripting example
"outputName": "myOutput"
context

(Optional)

The context parameter contains additional settings that affect task execution. For this task, there are four settings:

  • Extent (extent)—A bounding box that defines the analysis area. Only those features that intersect the bounding box will be analyzed.
  • Processing spatial reference (processSR)—The features will be projected into this coordinate system for analysis.
  • Output spatial reference (outSR)—The features will be projected into this coordinate system after the analysis to be saved. The output spatial reference for the spatiotemporal big data store is always WGS84.
  • Data store (dataStore)—Results will be saved to the specified data store. The default is the spatiotemporal big data store.

Syntax:
{
"extent" : {extent},
"processSR" : {spatial reference},
"outSR" : {spatial reference},
"dataStore":{data store}
}

f

The response format. The default response format is html.

Values: html | json

Example usage

The following is a sample request URL for JoinFeatures:

https://webadaptor.domain.com/server/rest/services/System/GeoAnalyticsTools/GPServer/GeneralizedLinearRegression/submitJob?predictionType=Train&inputLayer={"url":"https://webadaptor.domain.com/server/rest/services/Hurricane/hurricaneTrack2017/0"}&featuresToPredict={"url":"https://webadaptor.domain.com/server/rest/services/Hosted/corpusChristi/0"}&dependentVariable=ShelterCapacity&explanatoryVariables=CityDensity, ShelterLocations&regressionFamily=Binary&generateCoefficientTable=false&explanatoryVariableMatching=[{"predictionLayerField":"Hurricane2019","trainingLayerField":"hurricanesIn2019"},{"predictionLayerField":"ShelterLocations","trainingLayerField":"CorpusChristiShelters"}&dependentMapping=[{"value0":"Shelter"},{"value1":"NoShelter"}]&outputName=myOutput&context={"extent":{"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6,"spatialReference":{"wkid":4326}}}&f=json

Response

When you submit a request, the service assigns a unique job ID for the transaction.

Syntax:
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

After the initial request is submitted, you can use jobId to periodically check the status of the job and messages as described in Check job status. Once the job has successfully completed, use jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<analysis url>/JoinFeatures/jobs/<jobId>

Access results

When the status of the job request is esriJobSucceeded, you can access the results of the analysis by making a request of the following form:

http://<analysis-url>/JoinFeatures/jobs/<jobId>/results/output?token=<your token>&f=json

ResponseDescription
output

The output value will be the same geometry as the targetLayer value.

The targetLayer value will inherit all the attributes of the joined joinLayer value. If JoinOneToOne was applied, the output value will have a Count attribute, which is the number of features that matched the join conditions. By default, it will calculate all statistics for each field in the joinLayer value. If JoinOneToMany was applied, the output value will have each pair of joined features.

{"url": "https://<analysis-url>/JoinFeatures/jobs/<jobId>/results/output"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputName parameter provided in the initial request. The value contains the URL of the feature service layer.

{
"paramName":"output", 
"dataType":"GPRecordSet",
"value":{"url":"<hosted featureservice layer url>"}
}

See Feature output for more information about how the result layer is accessed.