Join a table to a feature layer in ArcGIS Online

Video

This tutorial is also available as a video.

Add a .csv file to a web map

To begin, you'll open a map in ArcGIS Online and review a feature layer of states and union territories in India. Then you'll download a .csv file of PHCs and add it to the map as a table layer.

  1. Open the India States and Union Territories web map.
  2. Sign in to your ArcGIS organizational account.
    Note:

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

    A map of India appears.

    Map of states and union territories of India

  3. On the Contents (dark) toolbar, click the Layers button.

    Layers button on the Contents toolbar

    The Layers pane appears. The map has one feature layer, India State Boundaries. Feature layers have both spatial information (the shapes and locations of the states visible on the map) and tabular information (an attribute table). Next, you'll add a .csv file as a table layer. Table layers are nonspatial: they only contain tabular information.

  4. Download the PHCs.csv file.

    This file contains information about the number of PHCs in urban and rural areas in India. PHCs are small clinics, and the most basic unit of the public health system in India.

  5. In the Layers pane, next to Add, click the drop-down arrow. Click Add layer from file.

    Add layer from file in the Layers pane

  6. Drag the PHCs.csv file to the Add Layer window.
    Tip:

    Alternatively, click Your device and browse to the .csv file.

  7. For How would you like to add this file, choose Create a hosted feature layer and add it to the map.

    The other option only works for tables that have latitude and longitude fields.

  8. Click Next.

    Five fields are listed. They match the column headers in the .csv file.

    Fields table

  9. Click Next.

    The next page gives you the option to define locations for the data using addresses or place-names. You will add your data as a nonspatial table layer instead.

  10. For Location settings, click Addresses or place names and choose None.

    Location settings set to None.

    Note:

    You could choose Addresses or place names and use the State / UT field to geocode your data, but this method would create a point layer, and for your map, you need a polygon layer with the states' boundaries.

    You can learn how to geocode a table in the tutorial Convert a list of historic places into a map.

  11. Click Next.
  12. For Title, type PHCs, followed by your name or initials (for example, PHCs Your Name).
    Note:

    You cannot create two layers in an ArcGIS organization with the same name. Adding your initials to a layer name ensures that other people in your organization can also complete this tutorial. Once a layer has been created, you can rename it in the map to remove your initials, which will not affect the name of the underlying data layer.

  13. For Summary, type Rural and urban Primary Health Centres (PHCs) in each state or union territory in India.
  14. Click Create and add to map.

    The map of India reappears.

  15. On the Contents toolbar, click the Tables button.

    The PHCs table is listed in the Tables pane.

    Tables pane

  16. In the Tables pane, click PHCs to open the table. Review the table's contents to confirm that the data was imported correctly. It should have five fields (columns) and 37 records (rows).

    PHCs table

Join a table to a feature layer

Next, you will join the table layer to the feature layer using the Join Features analysis tool. The result will be a new feature layer with the same shapes as the India State Boundaries layer and the same attributes as both the India State Boundaries and PHCs layers.

You'll start by finding a common field shared by both layers. You'll use this to link the correct rows in the table layer to the correct features in the feature layer.

  1. Click any orange area on the map.

    A pop-up appears, listing the layer's fields. The Name field contains the name of each state or union territory. This field matches the State / UT field in the PHCs table.

    Name field in a pop-up and State / UT field in the table

    You'll use the Name and State / UT fields to join the two layers.

  2. Close the pop-up and the table.

    Next, you'll open the Join Features analysis tool.

  3. On the Settings (light) toolbar, click the Analysis button.

    Analysis button on the Settings toolbar

    Note:

    If you do not see the Analysis button in Map Viewer, contact your ArcGIS administrator. You may not have the privileges required to perform analysis.

    Learn more about licensing requirements for spatial analysis.

  4. In the Analysis pane, click Tools.
  5. Under Summarize data, click Join Features.

    Join Features tool

  6. For Target layer, click Layer and choose India State Boundaries.

    This is the layer that will receive the joined fields.

  7. For Join layer, choose PHCs.

    This is the layer that will provide the joined fields.

    Input features

  8. For Join settings, set the following parameters:
    • Ensure that Use attribute relationship is enabled.
    • For Target field, choose Name and click Select.
    • For Join field, choose State / UT and click Select.

    Target and Join fields

    The join operation will only be able to join records in which the Name and State / UT attributes match.

  9. Ensure that the following parameters are set:
    • For Join operation, choose Join one to one.
    • For Multiple matching records, choose Only keep first matching record.
    • For Join type, choose Inner join.

    Join features settings

    When Join type is set to Inner join, any features that do not successfully match will be missing from the new layer. This will make it easier to find out whether the join operation was completely successful.

    Note:

    You can learn more about all of the settings in the Join Features tool in the documentation.

  10. For Output name, type PHCs Join, followed by your name or initials.
  11. Click Estimate credits.

    The join operation will use 0.073 credits. The number of credits is based on the number of features.

    Estimated credits

  12. Click Run.
  13. At the top of the Join Features pane, click the History tab.

    History pane

    The tool's status is shown here.

    When the tool completes, the output appears on the map. Three features are missing.

Edit the table

You'll review the missing features on the map. Then, you'll find these states or union territories in the PHCs table to learn why they did not join with the feature layer. You'll edit the table layer to make it match the feature layer so the two can join correctly.

  1. On the map, click each orange area to find the name of the state or union territory that did not join.

    Missing features on the map

    The missing features are Ladakh, NCT of Delhi (National Capital Territory of Delhi), and Dadra & Nagar Haveli & Daman & Diu (on the west coast, near the city of Nashik). The most likely reason why these features failed to join is because they were spelled differently in the two layers.

  2. Close the pop-up.
  3. In the Tables pane, click PHCs to open the table.
  4. In the table, scroll down to row 34.

    The spelling of either Delhi or NCT of Delhi needs to change before this record can join successfully. You don't have editing privileges on the feature layer, so you'll edit the table layer.

  5. In the table, double-click Delhi and type NCT of Delhi. Press Enter.

    Delhi changed to NCT of Delhi in the table.

    Rows 32 and 33 are the union territories of Dadra & Nagar Haveli and Daman & Diu.

    Rows 32 and 33 in the table

    These two union territories were merged in 2020, which explains why they are two records in the table layer, and only one in the feature layer.

  6. In rows 32 and 33, in the State / UT column, type Dadra & Nagar Haveli & Daman & Diu.

    Rows 32 and 33 edited to Dadra & Nagar Haveli & Daman & Diu.

    In the joined output, you need the numeric values from rows 32 and 33 to be added together to create the new PHC numbers for Dadra & Nagar Haveli & Daman & Diu. The expected new values are 13 (Rural PHCs), 2 (Urban PHCs) and 15 (Total PHCs). There is no need to edit the Rural PHCs, Urban PHCs, and Total PHCs fields. The Join Features tool can summarize them for you.

  7. On the table's header, next to State / UT, click the Options button and click Sort ascending.

    Sort ascending option in the table

    Scroll through the table to find the row for Ladakh. It is missing. There is no PHC data available for Ladakh.

  8. Close the table.

Run the join again

You'll run the Join Features tool again with the edited table layer. You'll change two of the tool's parameters: Multiple matching records and Join type.

  1. In the History pane, next to Join Features, click the options button and click Open tool.

    Open tool option in the History pane

    The Join features tool reappears. The parameters are already set with the choices you made earlier.

  2. Scroll halfway down the pane. For Multiple matching records, choose Summarize matching records.

    The table layer now has two records that will match to the same feature: Dadra & Nagar Haveli & Daman & Diu. Instead of just matching the first record, you want to summarize the numeric values from both records. Next, you'll tell the tool which fields to summarize and how.

  3. For Field statistics, click the Field button.

    Field button

  4. In the Add field window, select all three fields (Rural PHCs, Total PHCs, and Urban PHCs) and click Done.

    The three fields are added to the Join Features pane.

  5. Ensure that on each field card, Sum is selected.

    Three fields set to Sum.

    Now that you know the state names are all matching, you'll change the Join type. Last time, you only wanted to keep matching records so you could see what was missing. This time, you want to keep all records so Ladakh will still appear on the map, even though it has no PHC data.

  6. For Join type, choose Left join.

    Left join

  7. For Output name, type PHCs per state or union territory, followed by your name or initials.

    The tool will use 0.073 credits, the same number as last time.

  8. Click Run.
  9. On the Contents toolbar, click the Layers button.
  10. In the Layers pane, on the PHCs Join layer, click the Options button. Click Remove.

    Remove option on the PHCs Join layer

  11. When the tool has completed, zoom to and click Dadra & Nagar Haveli & Daman & Diu union territory, north of Mumbai.

    Dadra & Nagar Haveli & Daman & Diu pop-up

    In the pop-up, the last three fields show the following values:

    Sum Rural_PHCs13

    Sum Total_PHCs

    15

    Sum Urban_PHCs

    2

    These are the correct values that you expected from adding the Dadra & Nagar Haveli and Daman & Diu values together.

  12. Close the pop-up. Zoom out until you can see all of India.

Style the map with the joined data

To finish, you'll use the joined layer to visualize the PHC numbers on the map.

  1. On the Settings toolbar, click the Styles button.
    Note:

    If the Styles button is unavailable, in the Layers pane, click PHCs per state or union territory. The Style button is only available when a layer is selected.

  2. In the Styles pane, click the Field button.

    Field button in the Styles pane

  3. In the Add fields window, click Sum Rural_PHCs and Sum Urban_PHCs. Click Add.
  4. For Pick a style, scroll down and click Charts and Size.

    Charts and Size style

  5. Click Done.

    The data from the PHCs.csv table is now visualized on the map. You can see that with the exceptions of Delhi and Chandigarh, all states and union territories have more rural PHCs than urban ones.

    Final map of PHCs in India

  6. On the Content toolbar, click Save and open. Click Save as.
  7. In the Save map window, for Title, type PHCs per state or union territory. For Summary, type Rural and urban Primary Health Centres (PHCs) in each state or union territory in India.
  8. Click Save.

    The analysis history is saved with the map. Later, you can review the parameters you used each time you ran the Join Features tool.

In this tutorial, you learned how to use the Join Features tool to display tabular data on a map. You ran the tool and reviewed the results. You edited the table layer to create a closer match with the feature layer and ran the tool again. You learned about the difference between inner joins and left joins and how to summarize matching records.

You can find more tutorials in the tutorial gallery.