General Guide to Environmental Data and ArcGIS For ENVR468 Table of Contents Downloading Data from Internet Sources ...................................................................................... 2 Importing Data into ArcGIS ........................................................................................................... 2 Setting up the ArcGIS environment ............................................................................................ 2 Pre-viewing the Data and Description (Using ArcCatalog) ....................................................... 2 Exercise 1: Preview the Data and Descriptions using ArcCatalog ............................................. 2 Adding Shapefiles/Coverages ..................................................................................................... 3 Adding XY Events (i.e. Point Locations) ................................................................................... 3 Using Attribute Tables ................................................................................................................ 3 Joins and Relates ..................................................................................................................... 3 Editing Tables ......................................................................................................................... 3 Exercise 2: Adding XY Events ................................................................................................... 3 Checking/Changing/Matching Projected Coordinate Systems ................................................... 3 Check ...................................................................................................................................... 3 Change .................................................................................................................................... 4 Match ...................................................................................................................................... 4 Manipulating Data within ArcGIS .................................................................................................. 4 Categorizing Data ....................................................................................................................... 4 Changing Layer Properties ..................................................................................................... 4 Selecting Specific Data ........................................................................................................... 4 Other Useful Tools in ArcGIS .................................................................................................... 5 Saving GIS Data ............................................................................................................................. 5 Saving Individual Layers as Shapefiles & Projects .................................................................... 5 Layout View and Graphics ......................................................................................................... 5 Exercise 3: Saving GIS data ....................................................................................................... 5 Exporting GIS Shapefiles to MATLAB for BMElib track ............................................................. 6 Importing Shapefiles Directly Into MATLAB ........................................................................... 6 Creating ArcINFO Interchange Files (e00) for use in MATLAB .............................................. 6 Project Shapefile ..................................................................................................................... 6 Convert Shapefile to Coverage ............................................................................................... 6 1 Create e00 file ......................................................................................................................... 6 Importing the Graphic into MATLAB .................................................................................... 6 Exercise 4: Creating Arc Interchange file for use in MATLAB ................................................. 6 Downloading Data from Internet Sources 1. USGS Water Quality Data http://waterdata.usgs.gov/nwis 2. EPA STORET Water Data http://www.epa.gov/storet/dbtop.html For Data before 1999, choose the Legacy Database, after 1999, use Modernized. Some STORET Data and USGS Data may overlap but you should make sure of this when combining the data from these 2 sources. 3. EPA Air Quality Data Air Data: http://www.epa.gov/airdata/ NEI (National Emissions Inventory): http://www.epa.gov/ttnchie1/trends/ 4. Environmental Health Data CDC: http://www.cdc.gov/nceh/data.htm Importing Data into ArcGIS Setting up the ArcGIS environment 1. 2. 3. 4. Open ArcMap and click Customize>Toolbars. Make sure Spatial Analyst and Editor Toolbars are selected. Choose any other toolbars you want to appear. If the spatial analyst toolbar is not on your toolbars menu or if everything in it is grayed out then do the following: a. Go to Customize>Extensions>check the spatial analyst and click Close. b. Go to File>Map Document Properties>Navigate to a working folder>Click the silver cylinder with a star in the top right>Create a new geodatabase>Set this a the default geodatabase c. Go to File>Map Document Properties>Check the box next to ‘store relative path names’ Pre-viewing the Data and Description (Using ArcCatalog) 1. 2. 3. 4. 5. Open ArcCatalog. Navigate to the directory where your shapefiles/coverages are located In the left window, you can click on various GIS objects to view their attributes When you click on a particular object, the attributes will appear in the right window Generally there are 3 tabs in the right window a. Contents: basically the type of file (shapefile, coverage, point, etc.) b. Preview: lets you view the image of the object c. Description: lets you view some details about the data (spatial attributes, projections, etc.) Exercise 1: Preview the Data and Descriptions using ArcCatalog 1. Go to http://www.state.nj.us/dep/gis/stateshp.html and download the ‘Watershed Management Areas’ shape file aka ‘depwmas.zip’ to ‘D:\temp’ drive and unzip it. 2 2. Navigate to the directory where your shapefiles/coverages are located. If needed, connect to the folder by clicking on the folder with a plus called ‘Connect to Folder.’ 3. Preview the data in ArcCatalog- Refer to above directions. Adding Shapefiles/Coverages 1. Open ArcMap. 2. Click on the Add Data button (yellow square with black + ) or go to File Add Data. 3. Find the shapefile/coverage/table/layer that you would like to add, and Open it. Note: Arc 10 includes ‘Adding Data from ArcGIS Online,’ which is an online GIS database supported by ESRI. Adding XY Events (i.e. Point Locations) 1. 2. 3. 4. 5. Find the file which contains a list of Lat/Long for your station locations Make sure there are at least 2 columns in the file, one with LAT and one for LONG Open ArcMap. Using the ‘Add Data’ button, add the file that has the longitude/latitude information. Right click on the file and ‘Display XY Data’. Specify the X field (LONG) and Y field (LAT). Click OK the points should then appear in your view window in ArcMap. If they do not appear, you will need to check the projection (see below) Using Attribute Tables Joins and Relates Use Joins to Add Data to an existing attribute table. Use Relate when you have a 1-many or many-many relationship among data table. You must have an identical field in both tables to do a join/relate. 1. To Join tables right click a layer >join >choose the table and fields to join. 2. To Relate tables right click a layer>relate >choose table and fields to relate. Editing Tables 1. To edit values in an attribute table, you must open the editor toolbar (under Customize>Toolbar>Editor. 2. In the Editor Toolbar, click on Start Editing 3. Open the attribute table of interest and you can now change values and manipulate columns/rows 4. Click on Stop Editing when finished to save changes Exercise 2: Adding XY Events 1. Go to the class website for ENVR 468>Lecture Notes, and download ‘Phos_Data_and_Locations.dbf’ 2. Preview the data in Excel. The Site IDs have a Phosphorous value and a unique latitude and longitude location. 3. Open ArcMap. Click the ‘Add Data’ Button. Navigate to depwmas.shp from Exercise 1 and add it. 4. Click the ‘Add Data’ Button. Navigate to the ‘Phos_Data_and_Locations.dbf’ and add it. 5. In the table of contents, right click on the table. Go to ‘Display XY Data’. In the X field select ‘Longitude’, in the Y field select ‘Latitude’, in the Coordinate System section, click ‘Edit’. 6. Navigate as follows: Geographic Coordinate System>North America>NAD 1983. Click ‘OK’ then ‘OK’. Now your Water Quality is displayed on your map! Checking/Changing/Matching Projected Coordinate Systems Making sure your projections are consistent first will save a lot of time later when you are combining layers, etc. Check 1. In ArcMap make sure the layer/shapefile you are interested in is active. 3 2. Right Click on the layer>Properties. In the Layer Properties window, select the Source tab 3. The defined coordinate system will appear in the Data Source Box 1. In ArcCatalog select the layer from the left window. 2. Choose the Description tab in the right window 3. Select Spatial Attributes , the coordinate projection will show here Change 1. In ArcToolBox go to Data Management Tools>Projections & Transformation>Define Projection Wizard. 2. In the dialog box, find the shapefile/coverage, etc. that you need to define a projection for and click Next. Choose Select a Coordinate System. Then choose Select to use a predefined coordinate system. Navigate through either the Geographic or Projected Coordinate Systems until you find the one you need. Usually you will determine which coordinate system to use based on other shapefiles or layers you are using in your project (look at the Description) or perhaps from the literature 3. Once you have selected the appropriate coordinate system, it now becomes one of the attributes of your shapefile and you can match other layer’s coordinate systems to the one you just defined 1. In ArcCatalog right click on the file. Go to Properties>XY Coordinate System>Select. Match 1. Matching a projection or coordinate system is similar to defining a completely new projection for a GIS object. In ArcToolBox go to Data Management Tools>Projections & Transformations>Define Projection. 2. Choose Select a Coordinate System then choose Import 3. Find the layer/shapefile/etc. that already has a projection defined which you would like to use and click Apply now both projections should be defined in the same way 1. In ArcMap go to View>Data Frame Properties>Coordinate System Tab. 2. You can then select either a predefined projection or import a projection from another shapefile or coverage to match to the existing layer (using the Import button) Manipulating Data within ArcGIS Categorizing Data Changing Layer Properties 1. Right click on the layer>Properties. 2. Within properties you have several options (most useful are listed): General (change the layer name), Source (view coordinate system/source file), Symbology (view Data using categories/quantities/graphs), Categories (useful when you have unique values), Quantities (useful when you have data you want to aggregate and represent on the map), Fields (list the fields in your attribute tables), Joins/Relates (lists any tables/layers that are joined to the current layer). Selecting Specific Data To select by Location go to Selection>Selection by Location. Follow instructions to select features from one layer that interact (i.e. intersect, contain, etc.) features from another layer. 4 To select by Attribute go to Selection>Selection by Attribute. Use the simple query editor to define your selection. Double click the attribute on the left. Select an operator (AND/OR, >, < , =) and create an expression. Select a value for the expression. To select within a Table right click the layer and go to Open Attribute Table. You can click on a specific row in the table and select that feature it will then be highlighted both in the table and on the map view. To Save a selected layer right click the original layer you made the selection from. Go to Selection>Create Layer from Selected Features. Right click the new layer that was just added>Save Layer as File. A new layer may be automatically created when using ‘Select by Loc’ or ‘Select by Attribute’ In that case just right click layer>Save as layer. Other Useful Tools in ArcGIS 1. Buffer Wizard: Create buffers around features at a distance you specify 2. Geoprocessing Wizard: Lets you merge features in a layer, intersect layers, etc. 3. Geostatistical Analyst: Explore Data with graphs/charts Saving GIS Data Saving Individual Layers as Shapefiles & Projects Right click on each layer>Data>Export Data to export data as a shapefile. The Layer name should be the same as the file name Layout View and Graphics 1. For Layout View go to View>Layout View. This View allows you to create a map with legends/titles/annotation, etc. 2. In the Layout View go to Insert menu >and add legends/titles/arrows/scale bars 3. Go to File>Export Map to save the layout as a JPEG (or other graphics file type). Before saving shapefiles make sure ‘relative path names’ is set in File>Map Properties. Simply saving a layer will not save the data associated with the layer (i.e. symbology/categories etc. that you defined) You must save as a shapefile to include all attributes. 4. After you have saved all the shapefiles, you can save all of your work in a project file which will keep all of your active layers, their attribute tables, and any manipulation you have done to the files. Go to File>Save As to save a project. Exercise 3: Saving GIS data 1. To save an individual shapefile right click on the ‘Phos_Data_and_Locations Events’>Data >Export Data. Make sure that the layer name should be the same as the file name. 2. To save a Layout View or Graphics, go to the layout view (View>Layout view). This view allows you to create a map with a title/legends/titles/annotations/etc. 3. While in the layout view, go to the Insert>Title/Legend/etc. Create a map with a title and legend. Go to File>Export Map.... This allows you to save the map as a .jpeg or other graphic file types. 4. After all of the shapefiles are saved, you can save all of your work in a project file (.mxd), which will keep all your active layers, their attribute tables, and any manipulation you have done to the files. Go to File>Save or Save As. 5 Exporting GIS Shapefiles to MATLAB for BMElib track Importing Shapefiles Directly Into MATLAB In Matlab use the function ‘shaperead’ to read in the shapefile. Type in ‘help shaperead’ for details on syntax, etc. Creating ArcINFO Interchange Files (e00) for use in MATLAB Project Shapefile 1. Open ArcToolbox, click on Data Management Tools to see more options 2. Data Management Tools>Projections & Transformations>Feature>Project 3. In the dialog box that opens, navigate to the shapefile you wish to convert. You cannot have a path name containing spaces 4. Choose a file name for re-projected shapefile 5. Choose a Geographic Coordinate System (typically NAD83) by clicking on the box next to the ‘Output Coordinate System’ Field Convert Shapefile to Coverage 1. Open ArcToolbox. Go to Conversion Tools>To Coverage>Feature Class to Coverage 2. Select the re-projected shapefile from the ‘Project Shapefile’ section above 3. Select a new name for the coverage and click OK Create e00 file 1. Open ArcToolbox. Click on Coverage Tools >Conversion>From Coverage>Export to Interchange File 2. Select the coverage you want to convert 3. The new file with have the extension .e00 and is ready for import to MATLAB. You can look at an .e00 file with any text editor (wordpad/notepad) Importing the Graphic into MATLAB 1. 2. 3. 4. Open MATLAB. Navigate to the directory where the .e00 file is located Use the function ‘readARCe00.m’ to read in the e00 file (type ‘help readARCe00’ for syntax) A variable containing the Lat/Long of the shapefile will be created (called pVal) Use the ‘plot’ command to plot the shapefile within a matlab figure window (see help ‘plot’, ‘figure’, ‘readARCe00’) Exercise 4: Creating Arc Interchange file for use in MATLAB 1. 2. 3. 4. 5. If not already projected, define a projection for the ‘depwmas’ shapefile. Convert the shapefile to coverage. Create the .e00 file from the coverage file. Open MATLAB. In the BMELib directory, type ‘startup’. Go to the directory where your interchange file is located and type pVal=readARCe00(‘filename’); 6. To display the shapefile in a MATLAB figure type for i=1:length(pVal) plot (pVal{i}(:,1),pVal{i}(:,2) hold on end 6 7. Your NJ Watershed Management Area shapefile should be displayed! 7