Exercise 3 v.5 - Mapping Rainfall Data Using Spreadsheets (updated Nov 2003) Introduction - This is an assignment to continue expanding your GIS skills and start getting you prepped for some of the real-world issues you will encounter in your projects. In this assignment, you will: Retrieve a set of state boundaries from pre-packaged ESRI data Use the query builder to reduce the state set to New Jersey Make a new Theme of points where hypothetical rain gauge stations are located on a lat-long grid in New Jersey, both manually and automatically Join an externally-created spreadsheets to the attribute table of this theme containing rainfall amounts Label the points with the rainfall amounts Contour the rainfall amounts by hand and by machine. NOTE - It might be a good idea to set up a separate folder, within your own personal folder, for this exercise, in order to keep your files well-organized. 1. Bring a base map into Arcview Open Arcview, New Project, View 1, View - Add Theme Browse to C:\esri\esridata\usa on the computer's hard drive (not the Internet). A series of shapefiles show on the left side of the window. Select states.shp to bring into View 1. Turn the theme on (check small box). Notice that all the US states are shown. We don't need all this information. Open the attribute (theme) table for this theme, and notice that there are many fields, including a field called state_name. We can use the Query Builder to select NJ out of this data base ["state_name" = "New Jersey"]. Click on the query builder button and build this formula, like you did for your first exercise where you located your home with TIGER data. Make sure you have the "update values" box checked, which will allow you to select from a list of possible state names for the RH side of your formula (this may not have worked for the first exercise). After you build the formula, click the New Set button, and AV will select New Jersey in yellow. We can now use a nice feature in AV that allows to make a new shapefile of New Jersey only, based upon the selection highlighted in yellow in the states.shp attribute (theme) table. This is a useful feature, because you can create isolated shapefiles from huge databases, thereby saving time and space. With View 1 active, select Theme - Convert to Shapefile, browse to your individual folder, and save this new shapefile as something that makes sense (like njstate.shp). NOTE: NEVER save themes with default AV names, because they make no sense to you. You will not be able to keep track of what you've saved, and you will re-create the same themes and make the same mistakes repeatedly. This theme should appear in View 1. If it does not appear in your view, scroll to your folder and use View-Add Theme to add it to the view. Check the small box to turn it on. You should see just NJ. If the shape of NJ is still yellow, it is still selected in the theme table. Go to Theme - Table, and if the NJ line is yellow, go to Edit - Select None to return the state shape to its normal color. You can now delete the states.shp theme by using Edit - Delete Theme. AV will ask you if you want to delete the selected theme. Make sure it is the states.shp theme that is raised, and not the njstate.shp theme; otherwise, you'll lose the theme you just created. REMEMBER, the theme that is RAISED in the Table of Contents is the one that is ACTIVE. The little box with the checkmark makes the theme visible, but 1 visibility means nothing in terms of AV operations. Once you have deleted states.shp, you may wish to use File - Save Project As and save the project (in your folder on the server) in order to save what you have done thus far. Use a name such njrain.apr that you will remember and makes sense to you. Saving early and often is something that many computer professionals do on an ongoing basis. 2. Create a new point theme of rainfall gauging stations You will now perform some onscreen digitizing in order to create a New Theme of point data that will represent the locations of rainfall gauges throughout New Jersey. You are now going to place points representing the locations of rain gauges at specific points throughout the state of New Jersey. Your boss wants a map showing last year's rainfall throughout New Jersey for planning future sewer-handling capacity. She has given you the following list of gauge station ID numbers and location in geographic coordinates (decimal degrees, not deg-min-sec). You see that the points are uniformly spaced (0.25o apart). Your first job is to manually digitize the first 10 points into your view, in order for you to get a feel for this type of task, which is time-consuming but sometimes necessary in the workplace. The data are as follows: Station ID Longitude(oW) Latitude(oN) 1 -75.00 41.00 2 -74.50 41.00 3 -74.00 41.00 4 -75.00 40.50 5 -74.50 40.50 6 -74.75 40.75 7 -74.25 40.75 8 -74.75 40.25 9 -74.25 40.25 10 -75.00 40.00 Select View - New Theme. AV will prompt you to select the type of theme you want to create (point). When you click OK, AV will prompt you to name and save the theme before you make your first point. Make sure you browse to your folder on the server to save this theme, and use a name like Rain_Gauge_Locs Manual.shp (rather than an AV default name). Note that your view now has a rain gauges theme (along with njstate) in the Table of Contents. The small box is checked (theme will be visible) and has a dotted line around it, indicating you are in the "edit" mode. In this case you should already be in the editing mode. You can confirm this by selecting Theme and examining the menu. Notice that the first selection is "Stop Editing", which implies you are already in the "Start Editing" mode. If not in this mode already, select "Start Editing". Important: You must be in the "editing" mode before you create new features or make any changes to your themes. You will use the scrolling location bar in the upper RH corner of your view to guide your mouse location when you digitize. It is recommended that you zoom into your map to a scale of about 500,000, or big enough so that the latitude-longitude readings won't "jump" when you're trying to lock in a specific location with the LH mouse button. 2 When you manually digitize, there are two different ways to enter the points and their accompanying ID numbers. You can 1) enter a point, then type in an ID number in the attribute table for that point, or 2) you can plot all the points first and then fill in the ID numbers in the attribute table later. In this exercise we will do the former (1). I suggest you set up your screen so you have the View enlarged and to the right, with a long narrow space on the left to accommodate the attribute table, which will grow as you digitize in more points. With this setup, you can move back and forth between View and Theme table without one covering up the other as you alternately activate the view and the table for editing. Make sure that you are in the "editing" mode (see above) and make sure you have selected the "draw point" button . Scroll to -75.00, 41.00 and click on the LH mouse button to digitize the point. If you mis-plot the point, Don't Panic! Simply click on the black arrow button , select the mis-plotted point , and then you can either: 1) drag the point to the correct location, or 2) hit the delete key and replot the point. In either case, you must re-select the "draw point" button in order to plot points. You will enter an ID number for your first point right after you plot it. To do this, select and activate the rain gauges theme table. You may have to select Table Start Editing, but this is not always necessary. Notice that the default ID for that particular point is currently zero. Select the text editing button ][ select the zero, and type 1. Important - Press ENTER on the text portion of the keyboard (not the one with the numeric keypad) to save your change or it will revert back to the default value. Once you are ready to return to the view and plot more points, activate the View window, make sure that the draw point button is selected (it may have retained this status while your were table-editing), and draw in another point. Periodically during your drawing process, you will want to go to Theme - Save Edits, where you will be prompted to save the edits to rain gauges. shp. You want to say Yes, and the work you have done to date will be saved. When you are finished drawing your 10 points, use Theme - Stop Editing to stop the editing process. You will be prompted to save your edits, and you will say Yes if you are happy with the points you've drawn. By now, you are telling yourself "there must be a better way". Arcview can recognize columns of X,Y data in tables and automatically plot points through a series of steps you will learn below. First, however, you must create a table of data. Open MS Excel, select File - New. A blank spreadsheet appears. You will populate the spreadsheet with the 30 points of data listed below. IMPORTANT steps to follow in creating this spreadsheet: Be sure to type the column headers (ID, Longitude, Latitude) in row 1 Leave no empty rows or columns Make sure the latitude and longitude columns are formatted for 2 decimal places (Format - Cells - Number - 2 decimal places). Otherwise, the lat-long values will be automatically rounded by Excel to whole numbers. This will cause several points that should be separate points to plot on top of each other. 3 ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Longitude -75.00 -74.50 -74.00 -75.00 -74.50 -74.75 -74.25 -74.75 -74.25 -75.00 -74.50 -75.25 -74.75 -74.25 -75.00 -74.50 -74.75 -74.25 -75.00 -74.50 -74.75 -74.50 -74.75 -74.25 -75.00 -74.50 -75.25 -74.75 -75.00 -74.75 Latitude 41.00 41.00 41.00 40.50 40.50 40.75 40.75 40.25 40.25 40.00 40.00 39.75 39.75 39.75 39.50 39.50 41.00 41.00 40.75 40.75 40.50 40.25 40.00 40.00 39.75 39.75 39.50 39.50 39.25 39.25 When you've finished entering the data, select File-Save As; Save in (browse to your folder on the server); File name Rain_Gauge_Locs_Auto, "Save as type: Book 1”. IMPORTANT: USE UNDERSCORES (_) between file name words in order make sure there are NO SPACES BETWEEN WORDS, otherwise you will have error messages later when working with Spatial Analyst. This step will ensure that you have a copy of your work saved in Excel. However, ArcView does not read Excel. You will need to re-save this Excel file in dBase IV (.dbf). Make sure you select an active cell (like the upper left numeric cell where the ID number is 1). Click OK when Excel asks you if it's OK to save the only active sheet. Now exit out of the spreadsheet. Excel will continue to try to prompt you to re-save the file as Excel….you don’t need to do that. As long as you have the table saved in both .xls and .dbf formats in your folder, you’re OK. You must bring this new .dbf table into AV before you can use it to plot points. If necessary, re-open AV, go to the project window (njrain.apr) click on Tables, and select Add. An Add Table window will appear. Using Drives, browse to your folder on the server. Make sure you have List Files of Type: dBase (*.dbf) selected in the table window so that AV can find your Rain_Gauge_Locs_Auto.dbf table. Select 4 this table and click OK. With View 1 active, select View - Add Event Theme. You'll be prompted to select a Table, then an X field and a Y field that AV will use to automatically position the points. You should be able to tell which of these is latitude and which is longitude. North Y Field Values X field values Once the fields are selected, click OK. Rain Gauge Locs Auto.dbf appears in the T. of C. Now check the box to make the points visible. Remember, this is still a .dbf file, and it now must be converted to a shapefile before you procedd any further. Use Theme - Convert to Shapefile, browse to your folder on the server, and save the theme with a name that makes sense, such as Rain_Gauge Locs_Auto.shp. At this moment, your boss comes in and says, "Oops, I just found some more data for our map." Not to worry. You are now ready to learn another very useful skill. You are going to add new information to an existing AV attribute table from an external table using a technique known as Table Join. The end result will be a larger theme table, with the new information automatically added in new columns. 3. Create an external spreadsheet and Join it to a Theme Table Open MS Excel, and set up a spreadsheet with two columns of data - ID and 1999 Rainfall Amt (in). Make sure you create column headers in the first row of the spreadsheet, or the data will not be saved properly. Following are the new data for your 30 rain gauges that your boss just gave you: ID 1999 Rainfall Amt (in) 1 9 2 43 3 27 4 20 5 52 6 28 7 38 8 40 9 32 10 37 11 43 12 29 13 49 14 20 15 40 16 23 5 17 18 19 20 21 22 23 24 25 26 27 28 29 30 22 42 14 50 34 47 52 28 44 34 29 36 30 27 When you are done, you will save this table in a .dbf format, like you did earlier. Refer to those steps if necessary. After selecting a cell in the active portion of the table, save the table in your folder on the server, under a name you can remember, such as rainfall amount.dbf. You will now bring the .dbf spreadsheet into your AV project file, as you did earlier. Make the Project (not the View) window active and select the Tables icon. Then Select Add. The Add Table window comes up and prompts you to browse for a table to add to the project. Locate the rainfall amount.dbf spreadsheet that is in your personal folder. Remember to change the "List files of type" to dBase (dbf) in the left-hand window. Select rainfall amount.dbf, and it will appear in the Project window. Open (or activate) the Rain Gauge Locs Auto attribute table, so that both this and the rainfall amount.dbf table are visible in (or on top of) the Project (not View) window. Check to make sure that no records are selected in yellow in either table. If so, use Edit - Select None to clear the selection. Make sure you have both the external .dbf file and the attribute table visible, on top of the project window. You always join in the sequence from your external table to the attribute table. Select the “rainfall amount.dbf” spreadsheet header to make it active (blue), then click on the ID field header. Now click on the header bar of the attributes of rain gauge locs auto.shp table to make it active (blue), and click on that ID header too. Think about this…what you have just indicated to AV is that you want to join the rainfall amount data from the rainfall amount.dbf table to the attributes of rain gauge locs auto table (the Theme table), using the ID column as the primary key for the join. Select Table Join. You will see a new column in the attribute table, labeled 1999 rainfall amount. If this does not occur, this step was not completed properly. My advice, if you have problems, is to go back and follow my directions carefully. 4. Display and map the rainfall data by hand Once you have joined the 1999 rainfall data to your rain gauge locs auto theme table, you can use AV to map the 1999 NJ rainfall data. However, before you use the computer to contour the data, I want you to try it by hand. You will use the computer to print out the map you want to contour. With the View and Rain Gauge Locs Auto theme active (raised), Select Theme - Properties - Labels, and set the 6 text label so it will plot the rainfall numbers to the upper (or lower) right relative to a point. Then choose Theme - Auto-Label. Select the label field as 1999 rainfall amount. Select "use theme's label placement property"; say no to "scale labels", then click OK. Note that all the rainfall amounts are now plotted to the lower right of the appropriate point. Print this map out, and contour it before you go any further in the exercise. I want your interpretation before we use machine contouring. Show me your handdrawn map before proceeding, and include it in your writeup that you turn in. 5. Use Spatial Analyst to contour the data Discussion: Machine contouring is a science unto itself, and we could spend the whole course discussing different methods. Using the points designated as Zvalues, SA builds a flexible mesh in 3D, calculates the horizontal lines around this mesh, and then displays this information in 2D, either as a "chloropleth" style, shaded map, or as a set of coutours. Feel free to experiment with the various options available to you through AV. Below, I have suggested options that I personally think most closely represent how I would contour the data. Use File - Extensions to locate and check the Spatial Analyst extension. SA essentially converts AV from a vector to raster system in order to perform certain functions, such as contouring. A couple of additional buttons / columns become visible in AV. One of these is Surface. Make sure the rain_gauge_locs_auto.shp (NO SPACES BETWEEN WORDS!) theme is active (raised). The rainfall amounts from this theme will be used to make the grid that will then be contoured. Use Surface - Interpolate Grid, and a screen comes up asking for Output Grid Specifications. Use the defaults, and hit OK. Next, an Interpolate Surface screen comes up. Select Spline as the Method. Spline looks much smoother than the alternative, IDW. Remember to set your Z-value field as Rainfall Amount. Leave the weight at 0.1 and No. of points at 12 (how far out the computer searches when it builds its mesh). Set type to Tension. Click OK, and the computer will build a Surface Grid that represents the rainfall amounts. It will look like a hill. Now select Surface - Create Contours. Use the same settings as you did with the surface. I suggest a contour interval of 5 feet, with the base at 0 feet. You can overlay the contours on top of the surface theme, and they should look very similar. Note that the "zonation" that the surface theme uses is variable, although each zone appears to span more-or-less-equal segents of 7+ vertical feet, while the contours theme, while arbitrary, is more defined. Make and print a layout that shows the surface, points, contours, and the state outline of New Jersey. 6. Write up this exercise In about a page, indicate what you learned, what you liked and disliked about the exercise, and how you'd like to see this exercise changed in the future. Submit your maps and your writeup. 7