Example: Overlay : Intersect

In this example we use the Overlay : intersect operation in the Transform pane to trim a drawing of points so that all points which do not fall within areas in a second drawing are deleted.   At the end of the topic, we repeat the operation using the Join dialog in a different approach.


Our task in this example is to create a map that shows cities in the "lower 48" states of the US, a region often referred to by the abbreviation CONUS, for "Continental United States."   The region is a convenient one for examples because it fits on rectangular computer monitors without excessive white space to cover the great geographic extent of various US colonial holdings, territories, not-quite-states and so on.


We already have a drawing that shows the lower 48 US states as areas.   We have imported a drawing of US cities published as a shapefile by the National Atlas of the United States, a US government web site.   Our task is to trim that drawing to remove all cities that fall outside of the lower 48 states.



Our map uses a Bing streets imageserver layer as a background.   City points have been formatted with a different color for each state.


Looking at the two drawings together as layers in a map we see that there are many city points outside of the lower 48 states, spanning the entire world, from Alaska to distant settlements on Aleutian islands on the other side of the +/- 180 meridian that conventionally marks the end of West and the beginning of East.   There are also clumps of dots from US colonial holdings in the Caribbean in the Virgin Islands and Puerto Rico, dots for Hawaii and, of course, many dots for cities in Alaska.



Zooming in we see how most dots fall within the lower 48 states.



We would like to trim the cities drawing so that only dots that fall within the lower 48 states are left, as seen above.   But even that is not quite enough.


If we zoom in some more we can see that the data sets do not quite match.



In particular, the US states drawing is a simplified representation of US states that shows only the main areas of states.  It does not include islands and other small areas on which may be located towns.   



As seen above with the Bing layer turned off for greater clarity, some dots representing towns and cities do not fall within state areas, for example, those on Nantucket Island and on the island of Martha's Vineyard.  We will delete those as well.



Opening the cities table, we see that each city has a name and a two letter state code.



Opening the states table we see that it includes a field with the name of the state.   We will transfer that field as part of the intersect operation.



With the focus on the map window, in the Transform pane choose the Cities layer, and the Geom field.   Double-click the Overlay template to launch it.



In the Overlay template we choose the intersect operation.    For the Overlay layer we choose US states.  


We use the default Overlay {name} pattern for the Overlay fields box.   This parameter specifies how any fields brought over from the overlay drawing should be named in the result destination.


For the Result we choose New Table, and then we enter intersect cities for the name of the New drawing.  As we enter the name for the drawing, the pane will automatically fill in an analogous name for the table.   We can change that if we like.  The name could be anything, but we will use a name that reminds us of the operation used to create the drawing.


Press Transform.  


A new drawing called intersect cities  appears in the Project pane along with the new drawing's table.  We drag and drop the new intersect cities drawing into the Map.



The new intersect cities drawing layer appears in the map using default gray formatting.  In the illustration above, we have turned off the cities layer, to better see the new intersect cities drawing layer.



To compare the original cities layer to the new intersect cities layer, we turn the cities layer back on and we move it above the intersect cities layer.  We have formatted the intersect cities layer to use larger points, with white fill color.  That style makes it clear where points coincide in the cities layer and in the intersect cities layer.    We can see that the new intersect cities layer contains points at the same locations as the cities layer, except that those points from the cities layer which do not fall within, that is, intersect, one of the state areas, have not been transferred into the new intersect cities layer.



We use the Properties dialog to copy the StyleColorBack property value from the cities drawing to the intersect cities drawing, thus copying the style, to create the display above.


We can pop open the table for the intersect cities drawing created by the Overlay : intersect transform, to see what attribute fields have been copied over into the new drawing.



We see that the new intersect cities drawing has all the fields of the starting cities drawing, and in addition has acquired two new fields, called Overlay mfd_id, and Overlay STATE, from the overlay drawing.  We were able to use the same styling as the cities drawing, a thematic coloring using the STATE_CODE field, because the new intersect cities drawing inherited that field from the cities drawing.


In the Transform pane, we used the default Overlay {name} pattern for the Overlay fields box.   Fields brought in from the overlay have been named using that pattern.   For example, each cities record that falls within (intersects) a state area in the US states drawing has acquired the STATE field from that state, but named Overlay STATE so we can see that it came in from the overlay drawing.


With the focus on the open table, we can launch the Edit - Schema dialog to delete the Overlay mfd_id field (we do not need it, since we do not care what the mfd_id value was for overlaid states), and to rename the Overlay STATE field to simply STATE.  (Use of the Schema dialog not illustrated)






If we zoom out the map to include Alaska, Hawaii, and Puerto Rico, we see there are no points in the intersect cities layer outside of the continental US, that is, outside of the areas in the "lower 48" US states layer.  Mission accomplished.

Same Thing using the Join Dialog

The Overlay template and the operations it provides have been modeled on ESRI overlay operations, so ESRI users working with Manifold can have a familiar way of doing overlay operations like identity, intersect, union, and update.  Those are certainly convenient.   


However, much of what we do in GIS involves spatial operations that are really spatial JOIN operations, using classic spatial relationships like adjacent to, contained in, contains, intersects, and touches.   The Join dialog is often easier to use for such operations than ESRI-style overlays.   


Consider the following example, starting with our map and the cities layer:



With the focus on the cities layer within the open map window, we choose Edit - Join to launch the Join dialog.



In the Join dialog we choose US states in the upper right corner box as the joined drawing.   We choose contained in as the spatial join operation.  We use contained in instead of intersects, because intersects in spatial joins require an object to intersect the border of the intersecting object, so that points entirely within the interior of a state do not intersect that state.  See the discussion in the Join dialog topic.


We press the Add button, and in the pull down menu of fields available for transfer from the US states joined drawing, we choose STATE.   We leave copy as the default transfer method, and we leave STATE as the default name to use for the field when it is transferred into the cities table.   


Press Join Component.



There is no visible change in the cities drawing layer in the map, but if we look at the cities Table, we see that a new field called STATE has appeared.   The field contains NULL for each city that is not contained in one of the US states areas, and it contains the name of the state for each city that is contained in one of the US states areas.


To accomplish our task, we simply select all records with NULL in the STATE field and we delete those records.   That deletes all city points not contained within one of the US states areas.


With the focus on the open cities Table, in the Select pane we choose the STATE field, and then we double-click the NULL template to launch it.



In the Null template we choose null as the Condition and then press Select.  (The Condition box also allows us to choose not null if we want.)



The template immediately selects all records that have NULL in the STATE field.



Selected points also appear in red selection color in the map   We can see that we have selected all points which are not contained in one of the US states areas.


To delete those points, with the focus either on the cities layer in the map window or on the cities Table window, we either choose Edit - Delete or we press the Delete key.



The selected records are immediately deleted, both in the cities layer in the map and, of course, in the drawing's table as well.



All of the city records now have a STATE field value that is not NULL.  



CONUS means Continental - The region shown in our map of the "lower" 48 US states is referred to by the US government (including the US military) using the acronym CONUS.  By US Federal law the acronym CONUS means the "Continental United States" and refers to the lower 48 US states plus the District of Columbia but excluding Hawaii, excluding various overseas colonies of the US and excluding Alaska.      


Some people, perhaps embarrassed at the implied geographic illiteracy of implying that the mighty Alaskan peninsula is not an integral part of the continent of North America, will say the acronym means "Contiguous United States."  Endless web sites will provide false information such as ""Many people assume that acronym stands for CONtinental U.S. when it really stands for CONtiguous U.S."   Not so.   


Visiting the Code of Federal Regulations (CFR) at 45 CFR chapter 300, Part 300-3 "Glossary of Terms," section 300-3.1  we read the definition "Continental United States (CONUS) - the 48 contiguous States and the District of Columbia."  By law, as far as the US Code of Federal Regulations defines acronyms, Alaska is not a part of the continental United States.   Various style guides issued by the US military and US government bureaucracies also confirm that the acronym CONUS does indeed means Continental United States.  


What is that empty vertical lane in the data?  - Depending on how we format the data, we might see vertical empty lanes in the arrangement of cities.   For example, styling points in green color and

looking at the new cities Intersect drawing, we can see what appears to be a vertical lane from Missouri up into Michigan.  Why would there be such an empty, vertically oriented lane in the US?



Expanding the window to get a better look at the data we can see that the apparently empty vertical lane is just a consequence of how points are averaged out for display when too many of them are in the data to fit into all the pixels that are available in a given region of the monitor.


The illustration below shows a more zoomed-in view with city points reduced in size, which makes it clear there is no such empty vertical strip in the data.   But we can see what appear to be horizontal lines of towns and cities running across the Great Plains, for example, from Nebraska (light beige) to Wyoming (light gray).



Those horizontal lines of towns and cities are real data.  If we zoom in and increase the size of the city points we can see them even better.   



The horizontal lines of towns are the result of settlement patterns as the European population of the United States expanded Westward in the late 19th century, following the lines of railroads.   


Settlements naturally were founded and survived along the East to West railroad routes.   Many of those original railroads are long gone but their routes remain visible in the lines of towns and cities on the Great Plains.  Some additional lines can also be made out along the routes of railroads through the mountain passes and deserts of the "basin and range" geography further West.


What powered the immense wave of migration across the Great Plains?   - A wheat import from Russia.   Before the 1870's wheat varieties grown in the US were poorly suited to soil and climate conditions on the Great Plains.  All that changed when in the 1870's followers of an Anabaptist denomination emigrated from Russia to the US, bringing with them a variety of wheat called "Turkish Red" (known in the US as "Turkey Red") that grew well on the steppes of Russia.  The new wheat variety proved so spectacularly productive in the Great Plains that it made wheat farming profitable, leading to rapid expansion in farming and migration.


See Also



Style Pane


Transform Pane


Example: Merge : areas (dissolve) - In this example we combine multiple area objects into a single area object by using the Merge template in the Transform pane, using the areas (dissolve) option.  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: Use a Transform Expression to Create Buffers in a Drawing - Use the Expression tab of the  Transform pane 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 saving results to a new component and also the Edit Query button.