Qguis
Qguis
Qguis
use of Open Source software for GIS and spatial analysis. We will focus primarily on the programs Quantum GIS (aka QGIS), GRASS, and R. In this lab we give a basic introduction to QGIS. QGIS serves as graphical user interface for many GRASS functions, so to complete these labs you will only have to download this one set of GIS software. To download QGIS, visit the site http://www.qgis.org/ and follow the instructions. This lab set is based on QGIS version 0.8.1. You will need to download the lab data sets to complete these labs. If you want your directory structure to match that of the labs, you should store the unzipped files in the following directory structure: C:\QGISLab\BrownsPond C:\QGISLab\California C:\QGISLab\Wheat Vector Data 1. First, confirm that you can access the shapefile data. Start QGIS and either click on Layer->Add a Vector Layer:
Navigate to the folder C:\QGISLab\California and click on Counties. You should see a map of California appear on the screen. 2. The next step is to import the shapefile into GRASS GIS. A GRASS vector dataset is topologically correct in the same way as an ArcInfo coverage. To import the shapefile you must first create a GRASS location and mapset. A GRASS location is a location on Earth where you will construct some maps. A GRASS mapset is a particular set of maps within a location. Click on Plugins in the menu bar. If GRASS is not a selection, click on Plugin manager and check the box next to GRASS. Click on Plugins -> GRASS -> New mapset In the first window (GRASS database), click on the 3 dots and navigate to C:\QGISLab. Click Next.
In the next window, under Create a new location, type CalifGRASS. Click Next. In the next window, under Coordinate System, click on the Projection button. Click the plus sign next to Geographic Coordinate Systems and scroll down to NAD27. Click Next. In the next window select United States as the extent and click Set. Click Next. In the next window type CalifGRASSData as the new mapset. Click Next. Click Finish
Next, we will import the shapefile. Click on Plugins->GRASS->Open GRASS tools. You can also use the Open GRASS Tools button on the toolbar. It shows a pair of crossed hammers, Click on the Modules tab Scroll down to Import vector and select v.in.ogr Import OGR/PostGIS vector layer (the first of the two v.in.ogr choices). The window that appears should have counties in the OGR vector layer. Type countiesGR under Name for output vector map. Click Run. After the process finishes (it should say Successfully finished), click Close. You can now close the GRASS window. You have created a GRASS vector layer, located in your current mapset (CalifGRASSData). Click on Plugins->GRASS->Add a GRASS Vector Layer (or click on the icon), use Browse to navigate to gisdbase C:\QGISLab, location CalifGRASS, mapset CalifGRASSData, and select countiesGR. Ckick OK. You can now remove the shapefile counties if it is present (right click in the table of contents and select remove). NOTE: Labs often use layers created in earlier labs, so it will be a good idea to save the things you create in each lab. 3. We will repeat this procedure to import the hospitals shapefile to hospitalsGR and the intrst_highway shapefile to intrst_hwyGR. Do NOT create a new mapset each time; use the existing mapset. For the hospitals file the procedure is Repeat the step Add a Vector Layer to open the shapefile hospitals.shp as in problem 1. Repeat the steps using Plugins -> GRASS -> Open GRASS Tools -> v.in.ogr to import into GRASS as in Problem 2. 4. Use the Identify Features tool to find the name and population in 1990 of the 3 California counties on the Oregon border (the northern border of the state). The Identify Features tool is located furthest to the left in the second row of icons. Answers to all questions are at the end of the lab. 5. Use the Sort feature on the attribute data in the intrst_highway feature to find the route number and length of the fourth shortest interstate highway in California. Open the intrst_highwayGR attribute table and click on the DIST_MILES column heading. If this sorts from highest to lowest, click on it again and it will reverse the sort. What is its route number and distance in miles? Select this row in the attribute table by clicking on its row and zoom into it using Zoom to Selection (the icon is a magnifying glass over a dashed rectangle). Use the Identify Features tool to find what county it is in. Raster Data
GRASS cannot import an ArcGIS GRID directly. Instead the grid must first be converted to an ASCII file. This is done in Arc GIS using the Raster to ASCII tool located in the From Raster set of the Conversion tools. This creates a text file with the extension TXT. In order for GRASS to recognize this file the extension must be changed to ASC. You can open in Word the files rastert_field5y1.txt and field5y.asc in the C:\QGISLab\Wheat directory to view their contents. 6. Start QGIS or open a new project if QGIS is already running. Click on the Add a Raster Layer icon (immediately to the left of the Add a Vector Layer icon; see problem 1 above). Navigate to C:\QGISLab\wheat and select field5y.asc. Make sure the file type in the selection window is specified correctly as ArcInfo ASCII. The yield map of field 5 should appear. Now follow analogous steps to those of problem 2 to create a GRASS raster data set: Click on Plugins -> GRASS -> New mapset In the first window (GRASS database), click on the the Browse button, which is the button with three dots, and navigate to C:\QGISLab. Highlight the folder and click OK. In the next window, under Create a new location, type WheatGRASS (get the pun?). In the next window Under Coordinate System click on the Projection button. Click on Projected Coordinate Systems, select Universal Transverse Mercator and scroll down (its a long way!) to WGS84 zone 10N. Note that WGS84 Zone 10N has the EPSG ID number 32610. Once you know the EPSG ID of a projection you can speed things up by searching for this number. In the next window select United States as the extent. In the next window type WheatData as the new mapset. Click Finish. Next, we will import the raster data. Click on Plugins->GRASS->Open GRASS tools. Click on the Modules tab Scroll down to Import raster and select r.in.arc. In the window that appears under ARC/INFO ASCII raster file click on three dots, and navigate to C:\QGISLab\Wheat. Click on field5y.asc. Leave the other selections as their default and type f5yieldGR under Name for output raster map. Click Run. After the process finishes (it should say Successfully finished), click Close. You have created a GRASS raster layer. Click on Plugins->GRASS->Add a GRASS Raster Layer (or click on the icon), use Browse to navigate to gisdbase C:\QGISLab, location Wheatgrass, mapset wheatdata, and select f5yieldGR. If you still have the original ArcGIS ASCII grid you can now remove it. 7. Now repeat the procedure of problem 2 to add to import the vector shapefile field5samples to f5samplesGR. Do NOT create a new mapset each time; use the existing mapset wheatdata. Just do the two steps of Add a Vector Layer to open the shapefle and Plugins -> GRASS -> Open GRASS Tools -> v.in.ogr to import into GRASS. Finally, set the project properties to be the same as those of the mapset: Click on Settings -> Project properties Click on the Projection tab Select Projected Coordinate System and Universal Transverse Mercator Scroll down to WGS84 Zone 10N.
8. Select those points of the field sample data set with a weed rating equal to 5 (high weeds) by doing the following: 1) Open the f5samplesGR Attribute table (recall that this icon is second from the left in the second row). 2) Click on Advanced. Double click on WEEDS, single click on =, click on All, double click on 5. There is a prominent triangular shaped region in the field whose reduced yield seems to be due to high weeds (weeds equal 5). Click on the measure tool and measure the distance from the southern end of the field to this weedy area. What is it? 9. We will use the raster calculator to create a new layer of the field with yields greater than 7500 kg/ha. Start a new project. Using the same procedure as you used above, create a new mapset called Lab1 in the WheatGRASS location. Use Plugins -> GRASS -> Add Raster Layer (or the Add GRASS raster layer icon) to add the F5yieldGR raster layer. Select Plugins -> GRASS -> Open GRASS tools (or the GRASS tools icon) and scroll to r.mapcalc Raster map calculator (under Raster->Spatial Analysis-> Map Algebra). You will get a screen where the first four icons are Add map, Add constant value, Add Operator, and Add connection. Use the first to add the map f5yieldGR, the second to add the operator >=, the third to add the constant value 7500 (type the value in the long white space below the icons), and the fourth to add connections to make the screen look like the one below. This is tricky and will probably take a few attempts. Also, you may have to resize the original GRASS tools window to see the whole window. Type the name f5y7500 under Output. If you have it right it will look like this.
Once you have the system set up, click Run. If you get an error message, select Use Input Values. This will create a raster layer f5y7500.
Use Plugins -> GRASS -> Add Raster Layer to add this layer (you will have to navigate to the Lab1 mapset). The new layer will be almost all white. Double click on it and slide the transparency setting halfway to the right. You should now be able to see both the layers, similar to this.
Click on the image, move to the high yield area, and read the coordinates at the lower right of the screen to answer this question: which of the coordinate pairs below are in the largest area with yield in this range? __ 1) 592,080, 4,270,457 __ 2) 592,173, 4,270,682 __ 3) 592,462, 4,270,151 __ 4) 592,188, 4,270,500 10. Double click on f5yieldGR in the Table of Contents (alternatively, right click on it and select Properties). Click on Symbology and explore the various possibilities. Add the vector layer F5samplesGR and do the same thing. ANSWERS Problem 4. Modoc (9,678), Siskiyou (43,531), Del Norte (23,460) Problem 5 I780, 6.41, Solano Problem 8 280m Problem 9 1