Join Features

Join Features

The Join Features task works with two layers. Join Features joins attributes from one feature to another based on spatial, temporal, and attribute relationships or some 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 optionally join all features to the matching features or summarize the matching features.

Join Features can be applied to points, lines, polygons, and tables.

Request URL

http://<analysis url>/JoinFeatures/submitJob

Request parameters

Parameter

Description

targetLayer

(Required)

The point, line, or polygon features to be joined to.

Syntax: As described in detail in the Feature input topic, 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

Examples:

  • {"url": <feature service layer url>, "filter": <where clause>}
  • {"layerDefinition": {}, "featureSet": {}, "filter": <where clause>}

joinLayer

(Required)

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

Syntax: As described in detail in the Feature input topic, 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

joinOperation

(Required)

A string representing the type of join that will be applied.

Syntax: JoinOneToOne | JoinOneToMany.

  • JoinOneToOne—If multiple join features are found that have the same relationships 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 target 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 of sum is selected, 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. This is the default.
  • 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. There are no summary statistics calculated with this method.

Example: "joinOperation" : "JoinOneToMany"

joinFields

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

Syntax: "joinFields": [{"action": "<action>" , "field" : "<fieldname>", "to" : <new field name>"},...]

action can be the following:

  • remove—Remove a field from analysis and output .
  • rename—Rename a field before running analysis.

Examples:

  • [{ "action" : "remove", "field" : "fieldname1"}, { "action" : "remove", "field" : "fieldname2"}]
  • [{ "action" : "rename", "field" : "ZipCode", "to" : "Zip"}]

spatialRelationship

Defines the spatial relationship used to spatially join features.

Values: Equals | Intersects| Contains| Within| Crosses| Touches| Overlaps| Near.

Examples:

  • "spatialRelationship" : "Intersects"
  • "spatialRelationship" : "Near"

spatialNearDistance

(Required if spatialRelationship is Near)

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

Examples:

  • "spatialNearDistance" : 4
  • "spatialNearDistance" : 53.4

spatialNearDistanceUnit

(Required if spatialRelationship is Near)

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

Values: Meters | Kilometers | Feet | Miles | NauticalMiles | Yards

The default is Meters.

Example: "spatialNearDistanceUnit" : "Miles"

temporalRelationship

Defines the temporal relationship used to temporally join features.

Values: Equals | Intersects| During | Contains | Finishes | FinsihedBy | Meets | MetBy | Overlaps | OverlappedBy |Starts|StartedBy |Near.

Examples:

  • "temporalRelationship" : "Intersects"
  • "temporalRelationship" : "Near"

temporalNearDistance

(Required if temporalRelationship is Near)

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

Examples:

  • "temporalNearDistance" : 4
  • "temporalNearDistance" : 53

temporalNearDistanceUnit

(Required if temporalRelationship is Near)

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

Values: Milliseconds | Seconds | Minutes | Hours | Days | Weeks | Months | Years

Example: "temporalNearDistanceUnit" : "Minutes"

attributeRelationship

A target field, relationship, and join field used to join equal attributes.

Syntax: "attributeRelationship": "target.["target fieldname"] = join.["join fieldname"]

Examples:

  • "attributeRelationship" : "target['ZipArea'] = join['ZipCode']"
  • "attributeRelationship" : "target['OwnerId'] = join['InsuranceClaim']"

joinCondition

Applies a condition to specified fields. Only features with fields that meet these conditions will be joined.

Examples:

  • "joinCondition" : "target['health_spending'] > (join['income'] * .20)"
  • "joinCondition" : "target['health_spending'] > 8"
  • "joinCondition" : "log(target['results']) > 9.2"

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

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.

Syntax: [{"statisticType" : "<statistic type>", "onStatisticField" : "<field name>" }, ...]

fieldName is the name of the fields in the target layer.

statisticType is one of the following for numeric fields:

  • Count—Totals the number of values of all the points in each polygon.
  • Sum—Adds the total value of all the points in each polygon.
  • Mean—Calculates the average of all the points in each polygon.
  • Min—Finds the smallest value of all the points in each polygon.
  • Max—Finds the largest value of all the points in each polygon.
  • Range—Finds the difference between the Min and Max values.
  • Stddev—Finds the standard deviation of all the points in each polygon.
  • Var—Finds the variance of all the points in each polygon.

statisticType is one of the following for string fields:

  • Count—Totals the number of strings for all the points in each polygon.
  • Any—Returns a sample string of a point in each polygon.

Examples:

  • "summaryFields" : [{"statisticType" : "Mean", "onStatisticField" : "Annual_Sales"},{"statisticType": "Sum", "onStatisticField": "Annual_Sales"}]
  • Only return count: "summaryFields" : []

To return only Count: "summaryFields" : []

outputName

(Required)

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

Example: "outputName" : "myOutput"

context

Context contains additional settings that affect task execution. For this task, there are three 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}
}

f

The response format. The default response format is html.

Values: html | 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 Checking job status. Once the job has successfully completed, use the jobId to retrieve the results. To track the status, you can make a request of the following form:

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

Accessing 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

Parameter

Description

output

The output will be the same geometry as the targetLayer.

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

Example:

{"url": 
"http://<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.

3/3/2017