Join features

A join analysis resulting in a new layer that contains an additional field for average home value within census blocks.

What is a join analysis?

A join analysis is the process of combining the attributes from one feature dataset to another based on spatial and/or attribute relationships. The join data can be a feature layer or table. To execute the analysis, use the spatial analysis service and the JoinFeatures operation.

join features

Real-world examples of this analysis include the following:

  • Joining a table of flood data to a feature layer of county boundaries to visualize affected counties.
  • Joining the attributes of a land use data with zoning data to see discrepancies between zoning and use for each parcel.
  • Combining valve inspection records to fire hydrant locations to determine which hydrants are due for inspection.

How to perform a join analysis

  1. Review the parameters for the JoinFeatures operation.
  2. Send a request to get the spatial analysis service URL.
  3. Execute a job request with the following URL and parameters:
    • URL: https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/JoinFeatures/submitJob
    • Parameters:
      • inputLayer: The point, line, polygon, or table hosted feature layer that will have attributes from the joinLayer parameter appended to its table.
      • joinLayer: The point, line, polygon, or table hosted feature layer that will be joined to the targetLayer parameter.
      • attributeRelationship: Defines an attribute relationship used to join features. Features are matched when the field values in the join layer are equal to field values in the target layer.
      • outputName: A string representing the name of the hosted feature layer to return with the results.
  4. Check the status.
  5. Get the output layer results.

To see examples using ArcGIS API for Python, ArcGIS REST JS, and the ArcGIS REST API, go to Examples below.

URL request

Use dark colors for code blocksCopy
1
http://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/JoinFeatures/SubmitJob?<parameters>

Required parameters

NameDescriptionExamples
fThe format of the data returnedf=json f=pjson
tokenAn OAuth 2.0 access token.token=<ACCESS_TOKEN>
targetLayerThe point, line, polygon, or table layer that will have attributes from the joinLayer parameter appended to its table.{"url": <SERVICE_URL>, "filter": <where clause>}
joinLayerThe point, line, polygon, or table layer that will be joined to the targetLayer parameter.{"url": <SERVICE_URL>, "filter": <where clause>}

Key parameters

NameDescriptionExamples
attributeRelationshipDefines an attribute relationship used to join features. Features are matched when the field values in the join layer are equal to field values in the target layer.[{"targetField":"county","operator":"equal","joinField":"Area_Name"}]
joinOperationA string representing the type of join (JoinOneToOne or JoinOneToMany) that will be applied."joinType":"inner"
outputNameA string representing the name of the hosted feature layer to return with the results. NOTE: If you do not include this parameter, the results are returned as a feature collection (JSON).{"serviceProperties": {"name": "<SERVICE_NAME>"}}

Code examples

Join attributes from a table

This example uses the JoinFeatures operation to visualize counties with the highest recreation acreages. A feature table of recreation area values is joined to a polygon hosted feature layer by matching the Area_Name field values present in both feature layers.

In the analysis, the targetLayer value is the North Carolina regions hosted feature layer. The joinLayer value is the North Carolina resources table. The attributes of the joinLayer are appended to the targetLayer based on the values provided in the attributeRelationship parameter.

Join analysis joining a state recreation area table to polygon regions in North Carolina.

APIs

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
targetLayer = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/nc_regions/FeatureServer/0"

joinLayer = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/nc_resource_table/FeatureServer/0"

results = join_features(
    target_layer=targetLayer,
    join_layer=joinLayer,
    join_operation="joinOneToOne",
    attribute_relationship=[
        {
            "targetField": "county",
            "operator": "equal",
            "joinField": "Area_Name",
        }
    ],
    # Outputs results as a hosted feature layer.
    output_name="Join features results",
)

print(f"New item created : {results.itemid}")

Service requests

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded

&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
{
  "helperServices": {
    // Other parameters
    "analysis": {
      "url": "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
    },
    "geoenrichment": {
      "url": "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
    }
  }
}

Join attributes from a feature layer

This example uses the JoinFeatures operation to join home value data to census blocks. The attributes of the points that intersect with the polygons are joined, allowing you to visualize the census blocks by the average home value (AVGVAL_CY) field.

In the analysis, the targetLayer value is the Census Blocks hosted feature layer. The joinLayer is the San Francisco housing data hosted feature layer. The spatialRelationship parameter is set to intersects.

Join analysis joining average home values from a census centroid layer to census blocks in San Francisco.

APIs

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
targetLayer = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Census_blocks_within_San_Francisco/FeatureServer/0"

joinLayer = {
    "url": "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Centroids_for_San_Francisco_housing/FeatureServer/0",
    "filter": "AVGVAL_CY > 0",
}

results = join_features(
    target_layer=targetLayer,
    join_layer=joinLayer,
    join_operation="joinOneToOne",
    join_type="inner",
    spatial_relationship="intersects",
    # Outputs results as a hosted feature layer.
    output_name="Join features results",
)

print(f"New item created : {results.itemid}")

Service requests

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded

&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
{
  "helperServices": {
    // Other parameters
    "analysis": {
      "url": "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
    },
    "geoenrichment": {
      "url": "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
    }
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.