Skip to content

Instantly share code, notes, and snippets.

@kgjenkins
Last active July 25, 2016 19:39
Show Gist options
  • Save kgjenkins/23790f8b3a81b48e63eba1b79bbef0a1 to your computer and use it in GitHub Desktop.
Save kgjenkins/23790f8b3a81b48e63eba1b79bbef0a1 to your computer and use it in GitHub Desktop.
ArcGIS workshop for Soil and Water Lab

Workshop prepared for Cornell Soil and Water Lab, 2016-07-18, by Keith Jenkins, [email protected]

In this workshop, we will use ArcGIS to map an Excel spreadsheet of water sample data, called All_Water_Data_Tompkins.xlsx, which contains various measurements, along with longitude and latitude coordinates. We will explore the data in relation to local roads and hydrographic features.

Download the workshop data

Our initial spreadsheet of data

  • Preview the All_Water_Data_tompkins.xlsx spreadsheet in Excel, so we know what our data looks like. Notice there are 2 sheets.
  • Run ArcMap (Start menu > All programs > ArcGIS)
  • Add data > browse to the workshop data folder, select the .xlsx file (then select the TompkinsCoGWdata$ sheet)
    • (You will probably need to create a folder connection in ArcGIS before you can browse the folder, so click the folder icon with the "+" sign to "Connect To Folder")
  • Always make sure tables have imported correctly! In table of contents, right-click > Open

Convert to a point shapefile

  • Right-click the layer > Display XY Data
  • Be sure to assign a coordinate system! In the dialog, click "Edit", and select "WGS 1984"
  • Right-click the new TompkinsCoGWdata$ Events layer > Data > Export Data...
  • Save the file to the "output" folder as output/samplepoints.shp
  • Yes, add the exported data to the map as a layer!
  • We can now remove the original spreadsheet and the "events" layer from the project. Right-click > Remove
  • Note that a shapefile consists of several component files. An archaic format, but still very common.

Add context to the map

  • The points are floating in space... but we want to know where they are in the world.
  • Add data: boundaries/county_ny.shp
  • Read (but don't worry about) the warning about Geographic coordinate systems.
  • Add data: streets/roadcl.shp
  • The colors are probably awful, so double-click the symbol in under the layer name to edit.
    • county_ny: no fill color, outline width 3.0, outline color black
    • roadcl: color gray, width 1.0
    • samplepoints: color orange, size 11
  • Doesn't the map look a bit stretched? Let's "fix" the projection of our map!
    • View menu > Data Frame Properties
    • In the "Coordinate System" tab, scroll to the bottom, open "Layers" folder (which contains those used by current layers) and select "NAD_1983_StatePlane_New_York_Central_FIPS_3102_Feet"
    • This doesn't change any of our data files, just how it is display in this particular map.

Save your map

  • File > Save (or click the disk icon) to save the project (your map) to an .mxd file (ArcMap Document).
  • The .mxd file saves information about how the data is displayed, but points out to the original data files.
  • So always keep your .mxd and data files in the same containing folder, which you can then move to a USB drive, etc.

Explore the data

  • Select the "Identify" tool (blue circle with white "i") and click a point
  • Select points using the attribute table
    • Right-click the "samplepoints" layer > Open Attribute Table
    • Right-click the "C2H4_mgL" column header > Sort Descending
    • Click the square buttons to the left of rows to select -- both the row and the point on map are highlighted.
    • Ctrl- or shift-click to select multiple rows.
    • There is a button to clear the current selection.
  • Color-code by a specific attribute column
    • Right-click the "samplepoints" layer > Properties
    • In the "Symbology" tab, select "Quantities" and select a value column. (Then click "OK" or "Apply" to see the changes.)
    • Explore different parameters and color ramps.
    • Think about what different colors (especially orange or red) might imply ("alert!"). Also think about color blindness.
  • Add labels to help identify the sampling sites:
    • Right-click the "samplepoints" layer > Properties
    • In the "Labels" tab, check the box "Label features in this layer"
    • Set the "Label Field" to "ID" (you may need to scroll up the list to find it)
    • Adjust the font size, etc. as desired

National Hydrography Dataset

The National Hydrography Dataset (NHD) is a nation-wide dataset of surface water features. The NHD website (http://nhd.usgs.gov) has several ways of downloading the data (by subregion, subbasin, state, etc.) We'll be using a NY subset in FileGeoDatabase format. Don't try to mess with all those files in the .gdb folder -- ArcGIS (and few other programs) will know what to do with them.

The Watershed Boundary Dataset (WBD) is a companion dataset that delineates watersheds at different scales. Hydrologic Unit Codes (HUCs) with fewer digits represent larger regions, while HUCs with more digits represent smaller watersheds. The HUCs are hierarchical.

  • Add Data > browse to NHD_ny_tompkins.gdb. When ArcGIS looks in that folder, it sees several layers.
  • Add both the "WBD_HU8" and "WBD_10" layers.
  • The map is getting crowded! Move the county boundaries to the top, and turn off the road centerlines.
  • By toggling those layers on and off, explore their differences, and notice where the samplepoints are located.

Next, add these three main NHD layers, and explore the data near some of the sampling sites:

  • NHDFlowline : lines representing streams, rivers, canals, etc.
  • NHDArea : polygons representing selected significant flowline features (Cayuga inlet, major rivers, etc.)
  • NHDWaterbody : polygons representing lakes, ponds, etc.

The FCode values in the attribute table may be helpful to understand what types of features are being depicted. See Complete FCode list for NHD Hydrography Features.

Time permitting, take a look at these layers which are part of NHD, but perhaps not so useful since they are incomplete.

  • NHDLine : dams, etc.
  • NHDPoint : locations of waterfalls, springs, etc. (Notice that it is missing most of the local waterfalls!)

Clipping and subsetting

Notice that the NHDFlowline layer takes a while to draw -- it contains every stream in New York State! It will be helpful to clip this layer to just the area we need. There are multiple ways to do this.

Method #1: Clip to Tompkins County

  • Turn off all layers except "county_ny"
  • Use the select tool to select Tompkins County -- it will be highlighted in bright blue
  • ArcToolbox (red icon in toolbar) > Analysis Tools > Extract > Clip
  • Set "Input Features" = NHDFlowline
  • Set "Clip Features" = county_ny (if anything is selected, it will clip to the selected features)
  • Always pay close attention to where ArcGIS is trying to save the output!
  • Click the folder icon to browse to the output location -- save as output/tompkins_flowlines.shp
  • When the process completes (many seconds later), the output will appear on your map.
  • Notice that the county boundary was used as a cookie cutter. Sometimes this is adequate, but perhaps it would be better to keep whole watersheds intact.

Method #2: Keep all streams intersecting watersheds intersecting Tompkins County

  • Turn off all layers except "NHDFlowline", "WBD_HU10", and "county_ny".
  • With Tompkins County selected (see above), Selection menu > Select By Location
  • First, we'll select all the watersheds intersecting Tompkins County:
    • Target layer = WBD_HU10
    • Source layer = county_ny
    • Check the box "Use selected features"
  • Next, we'll select all the streams intersecting those watersheds:
    • Target layer = NHDFlowline
    • Source layer = WBD_HU10
    • Check the box "Use selected features"
  • Now we can save the selected flowlines to a new shapefile:
    • Right-click the "NHDFlowline" layer > Data > Export Data...
    • Export "Selected features"
    • Always pay close attention to where ArcGIS is trying to save the output!
    • Click the folder icon to browse to the output location -- save as output/tompkins_watersheds_flowlines.shp
    • Yes, add the exported data to the map.
  • You can now remove the original NHDFlowline layer from the map. (Right-click > remove)

This technique could be repeated for the other NHD layers.

Elevation

Elevation data is commonly distributed in a raster format, where each pixel is a number indicating elevation above sea level. In this example, elevation values are in meters, but it is always a good idea to check the metadata or other documentation, or else use the "Identify" tool to examine values at known locations.

  • Add Data > elevation/NED10m.tif
  • Turn off any other layers (like WBD_HU8) that might be obscuring the elevation data.
  • Change the display style (color ramp, etc.) by right-clicking the layer name > Properties > Symbology tab

Elevation hillshade

A hillshade is an shaded relief image generated by simulating the illumination of a 3D model of the elevation surface.

  • ArcToolbox (red icon in toolbar) > Spatial Analyst Tools > Surface > Hillshade
  • Set "Input raster" = NED10m.tif
  • Always pay close attention to where ArcGIS is trying to save the output!
  • Click the folder icon to browse to the output location -- save as output/hillshade.tif
  • Keep the default azimuth and altitude angles, which determine the angle of sunlight.
  • Set "Z factor" to 0.00001, which is the number of horizontal units (degrees) per vertical unit (meters)
  • When the process completes (many seconds later), the output will appear on your map.

To view both the hillshade and the color ramp, we can make the top layer slightly transparent:

  • Right-click the upper (hillshade) layer > Properties
  • Go to the "Display" tab, and set Transparency = 50%

Contour lines

It can also be helpful to view the data as contour lines, which are lines at regular intervals that each pass through pixels of the same values.

  • ArcToolbox (red icon in toolbar) > Spatial Analyst Tools > Surface > Contour
  • Set "Input raster" = NED10m.tif
  • Always pay close attention to where ArcGIS is trying to save the output!
  • Click the folder icon to browse to the output location -- save as output/contours5m.shp
  • Set "Contour interval" = 5 (this value is always specified in vertical units of the raster data)
  • Keep "Base contour" = 0, and "Z factor" = 1 (we don't need to adjust as long as we want meter contours)
  • When the process completes (many seconds later), the output will appear on your map.
  • Change the contour line color to black or dark gray.

Data sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment