Example: Overlay Contained

To explore the use of Overlay templates in the Transform panel we consider a quick tutorial example, using Overlay Contained.    A frequent use of overlays is to sum the values of many points that fall within an area and to transfer that sum to a new field for an area.  We may wish to sum the total sales for all customers in a given sales region and transfer that total sales amount to a new Sales field in a drawing of regions.


Overlay templates alter fields in the drawings upon which they work, in contrast to Overlay Topology templates which alter objects in the drawings upon which they work.


In this example we take a drawing that has cities in the US with a population value for each city.  We use Overlay Contained  to sum the population of each city within a state and to transfer that sum to a total population for the state.




We open a map that has two drawings as layers.  One drawing shows US cities as points.   The other drawing shows US states as areas.  We click on the US states tab to make that the active layer.  The US states drawing will be our target drawing and the US cities drawing will be our overlay drawing.



If we open the US states Table we see that it has a name for each state.  We would like to add a population field that is the sum of the populations for each city that is contained within the state.


Opening the US cities Table we see that each city has a Population value.   If we sum the Population values for each city contained within a state that is the value we would like for a new Population field for the state.    We will use the Overlay Contained template to do that.


We click on the US states tab in the map to ensure the US states drawing is the active drawing.  In the Contents pane we choose the Transform panel.   We choose the Geom field in the US states drawing as the target field.




We click the Overlay Contained template to choose it.  Since there is only one other drawing in the map the US cities drawing will automatically be loaded into the Overlay box.   




As soon as we choose the Overlay Contained template, the subject of the template, the US states layer, is shown in blue preview color, a visual display that helps us avoid errors by seeing in advance what the template will do.


Back in the Transform panel we click the Options button to specify which fields we would like to transfer and what transfer method should be used to transfer field values.





In the Transform Options dialog we change the transfer options for the Population field to sum and we set the transfer options for all of the other fields from the overlay drawing to ignore so they will not be transferred.   To keep the display from being cluttered an ignore choice is shown as a blank in the transfer column for fields that are to be ignored.    


We will leave as is the default suggestions for the names of the new components. We press OK.




Press the Add Component button to create a new component using the Overlay Contained template.



If we open the resulting new drawing we can see that, except for using default formatting, it looks exactly like the US states drawing.   That makes sense because it was created by transferring into the new drawing a copy of the geom field values of the US states drawing.




If we open the resulting new table we see that each record now has a new population field, prefixed with an o_ indicating it is the result of an overlay to give the name o_Population.   That new field gives the sum of all of the Population fields for each contained city point in the overlay drawing.   By summing the populations of all of the city points in each state we get a total population for each state.




If we like, we can use the Style panel in the Contents pane to format the fill color of areas in the new drawing based on the o_Population field.




The result is a thematic map display that colors the various states by their populations.   We have also used the Layers panel to specify a calm, beige color background instead of bright white.


1998 Data  - Residents of cities illustrated might notice the populations of their cities are slightly off the current population.  The data in this example were taken from US Census and National Atlas downloads that give populations as of 1998.


Approximations - Summing the populations of the largest cities in a state will result in a total population for the state that is lower than the true total, because people who live in small towns will not be counted.  That is OK for the purposes of this example, which is to show how to use Overlay Contained and not to provide an accurate population count for each state.


See Also



Contents Pane


Contents - Select


Contents - Transform


Transform Options


Transform Templates


Transform Templates - Drawings


Transform Templates - Geom


Transform: Overlay


Transform: Overlay Topology


Example: Overlay Containing - One of the most common uses of overlays is to transfer fields from areas to points that are contained in those areas.    Tasks such as transferring a census block group number or zip code number from a drawing of areas to points that fall within each area are extremely common.   In this example we transfer the name of a French region  to the points that represent cities which fall within each region.


Example: Overlay Topology Intersect - In this example we use the Overlay Topology, Intersect template in the Transform panel to trim a drawing of points so that all points which do not fall within areas in a second drawing are deleted.   The drawing of points we trim will become the US cities drawing that is used in the Example: Overlay Contained topic.


Example: Transfer Options and Merge Areas - Using the Merge Areas Transform panel template, an exploration of the difference between using Copy and Sum for transfer options.


Example: Union Areas - Combine multiple area objects into a single area.   A drawing of French regions shows some regions as more than one area.  We would like each region to be one area so the table of regions has one record per region.


Example: Construct JSON String using Select and Transform - Use the Select panel and the Transform panel to manually construct a JSON string using values from other fields in a table. Shows how we can manipulate text to build desired contents in a field.


Example: Edit a Drawing with Transform Templates - In this example we open a drawing and edit objects in the drawing using Transform panel templates.  Includes examples of using the Add Component button and also the Edit Query button.


Example: Use a Transform Expression to Create Buffers in a Drawing - Use the Expression tab of the  Transform panel to create three different sizes of buffers for different lines in a drawing and then automatically create a query which does the same thing.  Includes examples of using the Add Component button and also the Edit Query button.