Borrow attributes with a spatial join

Video

This lesson is also available as a video.

Review the data

You have a polygon layer representing urban areas in Chile. You want the attributes to include the city's names, but you would rather not enter all of the names manually. You'll review your data to determine whether name attributes can be joined from another layer.

  1. Download the Chile project package.

    A file named Chile.ppkx is downloaded to your computer. A .ppkx file is an ArcGIS Pro project package and may contain maps, data, and other files that you can open in ArcGIS Pro.

  2. Locate the downloaded file on your computer. Double-click Chile.ppkx to open it in ArcGIS Pro. If prompted, sign in with your ArcGIS account.
    Note:

    If you don't have access to ArcGIS Pro or an ArcGIS organizational account, see options for software access.

    A map appears, showing urban areas in Chile.

    Map of urban areas in Chile

    Note:

    The data for this map is from Natural Earth.

  3. On the map, click one of the polygon features.

    A pop-up appears, listing the feature's attributes.

    Pop-up for urban area polygon feature

    The attributes do not include the urban area's name.

  4. In the Contents pane, check the box next to Populated Places to turn this layer on.

    Points and labels appear on the map. Many of the points coincide with the polygons, but some do not. This is expected—the Populated Places layer includes regionally significant small towns and villages in addition to cities.

  5. On the map, click one of the point features.

    Pop-up for populated place point feature

    The pop-up shows many attributes for the point layer, including a name field.

  6. Close the pop-up.

Add a spatial join

You'll join the fields from the point layer to the polygon layer.

  1. In the Contents pane, right-click Urban Areas, point to Joins and Relates, and click Add Spatial Join.

    Add Spatial Join option in the layer context menu

    The Add Spatial Join window appears.

  2. For Target Features, ensure that Urban Areas is selected.

    This is the layer that will receive the new fields.

  3. For Join Features, choose Populated Places.

    This is the layer that will provide the new fields.

  4. For Match Option, choose Intersect.

    This option will choose any point feature that touches a polygon feature.

    Note:

    You can read about each spatial matching option at Select by Location graphic examples.

    Add Spatial Join window

  5. Click OK.

Review the join results

Next, you'll review the map to determine whether each city name that corresponds with an urban area was properly joined.

  1. On the map, click one of the urban area polygons.

    The pop-up includes many new attributes, including name.

    Pop-up for an urban areas polygon feature with name field

  2. Close the pop-up.

    Instead of clicking every polygon to see whether it has a name, you'll create a selection to visually distinguish between those that have names and those that don't.

  3. On the ribbon, click the Map tab. In the Selection group, click Select By Attributes.

    Select By Attributes button on the ribbon

  4. For Input Rows, choose Urban Areas.
  5. For Expression, build the query Where name is null.

    Query in the Select By Attributes window

  6. Click OK.
  7. On the map, review the selected features.

    These features have no name attribute, so they should not overlap with any point features.

    Selected polygon features on the map

    There are a few selected polygons that are very close to point features.

    Three selected urban areas near populated places points

    You'd like the join to include these features, even though they do not intersect. You'll redo the spatial join with a search radius so it includes points that are not only touching, but also nearby.

  8. On the map, review the unselected polygon features.

    These features have a name attribute, so they should overlap with a point feature. There are a few polygons that overlap with two points instead of one.

    Large urban area overlapping with two points

  9. On the map, click one of the polygons with two points.

    The name field contains only one of the city names. After you redo the join, you'll manually edit the name field to include both names.

  10. Close the pop-up.

Redo the spatial join

There were a few problems with your initial join, so you'll try again with some different parameters. This time, instead of the Add Spatial Join tool, you'll use Spatial Join. These two tools are very similar, but the results of Add Spatial Join are temporary and can't be edited, while Spatial Join produces a permanent and editable output layer. You'll use the Spatial Join tool because you need to be able to edit the name field afterward.

  1. On the ribbon, in the Selection group, click Clear.

    The results of the Add Spatial Join tool are temporary and can be easily undone.

  2. In the Contents pane, right-click Urban Areas, point to Joins and Relates, and click Remove All Joins.

    Remove All Joins options in the layer context menu

  3. In the Remove Joins window, click Yes.

    All of the joined fields are no longer present in the Urban Areas layer.

    Note:

    To make the results of the Add Spatial Join tool permanent, right-click the layer, point to Data, and click Export Features.

    Next, you'll open the Spatial Join geoprocessing tool.

  4. Above the ribbon, click Command Search and type spatial join.
  5. In the search results, click Spatial Join (Analysis Tools).

    Spatial Join tool in the command search menu

    The Geoprocessing pane appears with the Spatial Join tool parameters. They are almost the same as the Add Spatial Join parameters.

  6. For Target Features, choose Urban Areas. For Join Features, choose Populated Places.

    Unlike Add Spatial Join, the Spatial Join tool creates a new output layer, which requires a new name.

  7. For Output Feature Class, delete the existing text and type UrbanAreasNamed.
  8. For Join Operation, choose Join one to one.

    The other option, Join one to many, will create duplicate polygon features for urban areas that overlap with more than one point.

  9. Check Keep All Target Features.
  10. For Match Option, choose Intersect
  11. For Search Radius, type 2.5 and choose Kilometers.

    The tool will join fields from any point that is within 2.5 kilometers of a polygon. This should be enough distance to catch those points that are near polygons.

    Spatial Join parameters in the Geoprocessing pane

  12. Expand the Fields section.

    Before, you joined all fields from the Populated Places layer. However, this layer has many fields, and the only one you need to include in the join is name. You'll use the Field Map to determine which fields come from the Populated Places layer and remove all but the name field.

  13. Under Output Fields, click Shape_Area.

    Under Source, the Urban Areas field is listed as the source of the Shape_Area field.

    Shape_Area field from the Urban Areas layer in the Field Map

    All of the fields above Shape_Area also come from the Urban Areas layer. You'll keep all of these fields.

  14. Under Output Fields, click scalerank_1.

    Under Source, the Populated Places layer is listed as this field's source. All of the fields below it also come from the Populated Places layer.

    Fields from the Populated Places layer in the Field Map

    You'll remove all of them except for name.

  15. Under Output Fields, point to scalerank_1 and click the Remove button.

    Remove button on the scalerank_1 field

  16. Remove all of the fields below Shape_Area except for the name field. Hold the Shift key to select multiple fields at once.

    Final Field Map with seven remaining fields

    Note:

    To learn more about field maps, try the lesson Merge multiple layers into one.

  17. Click Run.

    When the tool completes, a new layer, named UrbanAreasNamed, appears on the map.

  18. In the Contents pane, turn off the Urban Areas layer.
  19. On the map, zoom to one of the urban areas that is near, but not touching a point. Click the polygon and confirm that the pop-up contains a name attribute.

    Pop-up with the name field

  20. Close the pop-up.

Edit the new layer

Now that you have created a new layer with a joined name field, you can edit it to include extra city names. You'll use the Select By Attributes tool and the Attributes pane to update the larger urban areas.

  1. On the ribbon, click the Map tab. In the Selection group, click Select By Attributes.

    You'll select all polygons that overlap with more than one point.

  2. For Input Rows, choose UrbanAreasNamed.
  3. For Expression, build the query Where Join_Count is greater than 1.

    Query in the Select By Attributes window

    The Join_Count field was created by the Spatial Join tool.

  4. Click OK.
  5. On the ribbon, in the Selection group, click Attributes.

    Attributes button on the ribbon

    The Attributes pane appears. The upper half of the pane lists all of the selected features. The lower half lists the attributes for one of the selected features.

  6. In the upper half of the Attributes pane, right-click Coquimbo and click Zoom To.

    Zoom To option in the selected feature context menu

    The map zooms to the selected feature. This area covers two cities: Coquimbo and La Serena.

  7. In the lower half of the Attributes pane, in the name row, click Coquimbo and type Coquimbo, La Serena.
  8. Check the Auto Apply check box.

    Edited name attribute and Auto Apply check box in the Attributes pane

  9. Zoom to each of the selected features and update their name attributes with the following text:
    • Santiago, San Bernardo
    • Talcahuano, Concepción
    • Viña del Mar, Valparaíso

    Updated names of selected features

    Finally, you will save the edits.

  10. On the ribbon, click the Edit tab.
  11. In the Selection group, click Clear. In the Manage Edits group, click Save.

    Clear button and Save button on the ribbon

  12. In the Save Edits window, click Yes.
  13. On the Quick Access Toolbar, click Save.

    Save button on the Quick Access Toolbar

In this lesson, you joined an attribute from one layer to another. The join was determined by a spatial relationship between the two layers, rather than by a common field. You learned how to add and remove joins, the difference between the Add Spatial Join and Spatial Join tools, how to use Select By Attributes to review the results of a join, and how to edit features in the Attributes pane.