We use the Split template cut operation to split interstate highways in the US by boundaries of US states, and then we transfer a state name to highway lines within that state by using the Join dialog.
See the video version of this topic in the 5 Minute Tutorial - Split Highways by State video.
We will use a map with two vector drawing layers. The US states layer shows states in the US as polygonal area objects. The Interstates layer shows interstate highways in the US as line objects. The interstate lines include some long lines that cross the entire country. We have ctrl-clicked on two of the lines in the above illustration to show how ctrl-clicking just one part of a long line selects the entire line.
We would like to split the long highway lines at the boundaries of each state. That would allow us to select only those highway lines that fall within a particular state.
Opening the tables for the Interstates and US states drawings we can see that the US states Table has an attribute field called State that gives the name for each state. After we use the Transform pane Split template to split the highway lines by the boundaries of states, we will use the Join dialog to add a State field to each resulting highway line to give the name of the state in which that line is located.
With the focus on the map window, in the Transform pane we choose the Interstates layer and the Geom field in that layer (the geometry field).
We double-click the Split template to launch that template.
In the Split template we choose the parts operation, and we choose the US states layer as the Cut with layer. We choose New Table for the result and specify Highways by state as the name for the new drawing that will be created, also specifying an analogous name for the new drawing's table.
Press Transform.
A new Highways by state drawing and table appear in the Project pane. We drag and drop the new Highways by state drawing into the map. We also turn off the Interstates layer to hide it from view.
We cannot see the breaks in the lines, but we know that the lines in the Highways by state layer now consist of multiple lines that join each other end to end at state boundaries.
We will now use the Join dialog to join state names into highway lines that fall within each state. This is an operation sometimes called a topology overlay operation in some GIS packages, but it is just a spatial join.
We click the Highways by state layer tab to make sure it is the active layer tab, and then with the focus on the map window we choose Edit - Join to launch the Join dialog.
In the Join dialog, we choose US states as the joined drawing in the upper right hand corner of the dialog. The Geom field will be our joining key field for both the Highways by state and the US states drawings. We choose contained in as the join criterion. The join is based on finding all highways that are contained in each state.
We press the Add button to add a new field to the Highways by state layer as a result of the Join.
In the pull down menu listing available fields that can be joined in from the US states table, we choose the State field.
The default way to join in the State field from the US states drawing into a new field in the Highways by state drawing is to simply copy the value from the State field into a new field called State in the Highways by state drawing. That works for us.
Press Join Component.
A new field called State appears in the Highways by state Table. For each of the highway lines within a given state, the name of the state appears in the new State field, joined in from the US states drawing using a spatial join.
We can style the Highways by state drawing using a thematic format that colors the highway lines based on the name of the state given in the State field for each highway line. In the illustration above, we have added a dark background layer using the Canvas world dark gray base web server, and we have quickly created a version of the US states layer that has transparent fill color and just shows black outlines for the states, to provide context.
The illustration shows at a glance how all of the highway lines have been split into separate lanes at the borders of states.
5 Minute Tutorial - Split Highways - In only five minutes we use the Split template cut operation to split interstate highways in the US by boundaries of US states, and then we transfer a state name to highway lines within that state by using the Join dialog. We round out the video by styling the result for a really super display.
Example: Flooded Roads - We consider a hypothetical case of a 10 meter rise in sea level in the San Francisco Bay area, and we find what highways and major roads would be flooded by such a rise. The example uses both raster and vector data sets, combines a number of techniques and uses the Contour, Buffer, Merge, and Clip transform templates.