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.
- Open the India States and Union Territories web map.
- 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.
- On the Contents (dark) toolbar, click the Layers button.
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.
- 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.
- In the Layers pane, next to Add, click the drop-down arrow. Click Add layer from file.
- Drag the PHCs.csv file to the Add Layer window.
Tip:
Alternatively, click Your device and browse to the .csv file.
- 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.
- Click Next.
Five fields are listed. They match the column headers in the .csv file.
- 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.
- For Location settings, confirm that None is selected.
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.
- Click Next.
- 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.
- For Summary, type Rural and urban Primary Health Centres (PHCs) in each state or union territory in India.
- Click Create and add to map.
The map of India reappears.
- On the Contents toolbar, click the Tables button.
The PHCs table is listed in the Tables pane.
- 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).
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.
- 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.
You'll use the Name and State / UT fields to join the two layers.
- Close the pop-up and the table.
Next, you'll open the Join Features analysis tool.
- On the Settings (light) toolbar, click the Analysis button.
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.
- In the Analysis pane, click Tools.
- Under Summarize data, click Join Features.
- For Target layer, click Layer and choose India State Boundaries.
This is the layer that will receive the joined fields.
- For Join layer, choose PHCs.
This is the layer that will provide the joined fields.
- For Join settings, set the following parameters:
- Ensure that Use attribute relationship is enabled.
- For Target field, choose Name.
- For Join field, choose State / UT.
The join operation will only be able to join records in which the Name and State / UT attributes match.
- Ensure that the following parameters are set:
- For Join operation, ensure that Join one to one is selected.
- For Multiple matching records, choose Only keep first matching record.
- For Join type, choose Inner join.
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.
- For Output name, type PHCs Join, followed by your name or initials.
- Click Estimate credits.
The join operation will use 0.073 credits. The number of credits is based on the number of features.
- Click Run.
- At the top of the Join Features pane, click the History tab.
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.
- On the map, click each orange area to find the name of the state or union territory that did not join.
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.
- Close the pop-up.
- In the Tables pane, click PHCs to open the table.
- 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.
- In the table, double-click Delhi and type NCT of Delhi. Press Enter.
Rows 32 and 33 are the union territories of Dadra & Nagar Haveli and Daman & Diu.
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.
- In rows 32 and 33, in the State / UT column, type 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.
- On the table's header, next to State / UT, click the Options button and click Sort ascending.
Scroll through the table to find the row for Ladakh. It is missing. There is no PHC data available for Ladakh.
- 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.
- In the History pane, next to Join Features, click the options button and click Open tool.
The Join features tool reappears. The parameters are already set with the choices you made earlier.
- Scroll halfway down the pane. For Multiple matching records, choose Calculate field statistics.
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.
- For Field statistics, click the Field button.
- 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.
- Ensure that on each field card, Sum is selected.
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.
- For Join type, choose Left join.
- 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.
- Click Run.
- On the Contents toolbar, click the Layers button.
- In the Layers pane, on the PHCs Join layer, click the Options button. Click Remove.
- When the tool has completed, zoom to and click Dadra & Nagar Haveli & Daman & Diu union territory, north of Mumbai.
In the pop-up, the last three fields show the following values:
Sum Rural_PHCs 13 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.
- 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.
- 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.
- In the Styles pane, click the Field button.
- In the Add fields window, click Sum Rural_PHCs and Sum Urban_PHCs. Click Add.
- For Pick a style, scroll down and click Charts and Size.
- 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.
- On the Content toolbar, click Save and open. Click Save as.
- 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.
- 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.