Spatial Join Example: Add State Names to Cities

Spatial joins between drawings use spatial relationships between the geometry of objects in the source, joined drawing and the geometry of objects in the target, original drawing to join data into the original drawing.   The Edit - Join dialog provides spatial joins between drawings that are layers in maps.    Spatial joins done by the Join dialog are an easier way to accomplish classic GIS "overlay" operations.    Spatial joins work between drawing layers in the same map.  Layers can be in different data sources.


Overlays in ESRI nomenclature are called spatial joins in the data science / IT world, two different terms to describe exactly the same thing.  The Edit - Join dialog is a more modern way to do the same jobs with easier workflow.  Edit - Join, for example, updates the target table or drawing in place.   Even skilled ESRI people often prefer Edit - Join.


Add fields using a spatial join:


  1. With the focus on a drawing layer in an open map window, choose Edit - Join.
  2. In the upper right box choose the joined drawing in the map from which fields will be joined.

  3. In the second row of boxes, choose the geometry fields to use and the spatial method, such as contains or contained in.

  4. Click the Add button to choose a field in the joined drawing's table that will provide data for a new field in the original table.

  5. Double-click a cell to edit the field name (new fields) or to choose a different source field (joined table) or to choose a different transfer method.

  6. Press Join.


This example provides a drawing to drawing spatial join:  Given a drawing of cities and a drawing of states in the US, we copy the name of the state in which it is located to each city.  


This example is basically the same as example in the Spatial Join Example: Add Names of Provinces to Cities topic, but using cities in the US and states in the US instead of cities and provinces in France.  


Using a map that has a drawing showing cities in the US and a layer showing states in the US, we will add the name of each state in which it is located to each city.   


See the video version of this example in the Join Dialog Part 1 -  Spatial Joins video.  



We start with a map of the US that has a layer called US cities that shows major cities in the US as points, and a layer called US states that shows lower-48 states in the US as areas.  


Opening the US cities Table we see that the drawing has the name of each city and the population of that city.   It does not have the name of the state in which the city is located.



Opening the US states Table we see it has the name of each state.   We would like to copy the name of the state for each city into a new field, called State, in the US cities drawing.


With the focus on the US cities layer in the open map window, we choose Edit - Join from the main menu.



We choose the US states drawing as the joined drawing.   We choose contained in as the spatial method for the join.  We want to match all cities contained in each state with that state.


 Press the Add button to add a new field. the State field, from the joined drawing.


Press Join.



A new State field is added to the US cities Table.  The name of the state for each city is copied from the US states Table into the new field in the Cities Table.



Terminology - The original table also may be called the target table, and the table providing data also may be called the source table.


Quick reference - With the Join dialog open, press F1 to open a quick reference guide in a browser window.


Guessing the key field - When we launch the dialog with an original field and when we choose a joined field, the dialog will try to guess what fields we might want to use as key fields and will load those first by default.  If it guesses wrong, we can choose the field we want.   For the original table, the dialog tries to use a field (other than mfd_id) that has a BTREE / BTREENULL index, with a data type preference for numbers, then text, then everything else, and a name preference for field names with id in them, such as ... id or ..._id, then and then everything else. For the joined table, the dialog uses similar logic, but first tries to use a field with the same name as in the original table.


Added fields are static - Added fields are static, that is, if data in the joined table changes the fields in the original table that received data in the Join operation from the joined table will not automatically be updated.  We can easily update the table any time we want using a saved update query.  


Spatial joins are automatically parallel - Joining data between drawings uses parallel GeomOverlay function variants.  Joins from images to drawings are parallelized through a nested SELECT using THREADS.



See the Join Videos list of videos showing how to use the Join dialog.

See Also











Editing and Combining Data




Join Videos


Join Examples


Command Window


JOIN Statements


Editable Results Tables