QGIStutorial_qgis2on..

advertisement
USING QUANTUM GIS FOR FIELD GEOLOGY
By: Terry L. Pavlis and Richard Langford, Univ. Texas at El Paso
There are Three Basic Parts to this Tutorial:
I. Using QGIS
II. Setting up and using QGIS for field Geology
III. An introduction to creating your own forms and symbols
1
Introduction and Overview of QGIS
When the ipad first came out it quickly became apparent that mobile computing was about to go
through a major change. We realized at that time that Microsoft was going to have to change to adjust
to the mobile computer market, and when we realized that ESRI was going to continue to cling to
windows mobile we decided we needed to look for a new software platform. We also realized our
existing winmobile equipment was quickly becoming archaic, and we needed to find another solution.
Some people (e.g. Steve Whitmeyer, and others) have gone one route, the ipad route, with aps for
ipad. The UTEP group chose, however, to try a different approach. We currently use ArcPad on
Windows 8 tablets. However our favorite method is using the open source GIS application Quantum GIS
(aka QGIS). We had already been encouraging students to learn the basics of QGIS, because it runs on
almost every platform (interesting, the only exception is iOS, the ipad and iphone OS—it is apparently
because of the open source initiative, and Apple’s policy with iOS). Students can load the software on
their own laptops, and not have to stand in line for our limited number of laptops. This was particularly
important for mac and linux users where the software runs flawlessly (probably the best platforms for
the software).
In mid-2012 one of us (Pavlis) launched into building a full user interface for QGIS that was
comparable to our ArcPad project, and the results are the files included in this tutorial set. The tradeoff
with open source, of course, is it is not as polished as commercial software and as a result some aspects
are more user hostile. We’ve tried to minimize the user issues in this tutorial, but unlike our arcpad
projects this software requires more setups . We have now tested the program with both graduate and
undergraduate classes. So we are reasonably confident it is ready for prime time—aside form some
small glitches.
Another issue with open source software is there are limited resources to draw on to get help,
although through personal experience (TP and RL) the open source community is often a better source
of help than ESRI with academics because ESRI’s policy places limits on getting software help (at least in
our case, each institution has a gatekeeper who you have to go through to report issues or get help
beyond the manuals). All whining about ESRI aside, the qgis community can be very helpful. Even just
going to their forums and finding old posts that are likely to be the same problems you have. Be advised
though, they are often rather geeky, and not necessarily easy to work from if you’re not comfortable
speaking computereeze. If you really are going to get into tapping the full value of QGIS, it is probably a
good idea to learn simple python programming or C++ as you can often work around bugs with a simple
script. Moreover, that is how you develop plugins for QGIS, and it has some excellent plugins
Although QGIS is a potential “goldilocks” program, you need to be aware of other issues before
launching into this program. The program is very stable on Windows, Linux and Mac, so if you want to
use one of those platforms, this is potentially the application for you. This is particularly true with the
new generation of windows tablets that are inexpensive and great field computers. We would continue
with arcpad, but the writing seems to be on the wall that this software won’t be supported much longer;
thus, the move to QGIS. Unfortunately, as of this writing the Android version of the program is
unusable. We are hopeful that these problems will eventually be fixed, and if so, the android platform
would be superb for this application. For example, one of the greatest potentials for the android
platform is an inexpensive device that almost everyone might have, including a phone, and built in GPS
capabilities. (There is a GPS issue with windows 8 that doesn’t allow built in GPS devices to function—
thank you Microsoft…)
2
With those cautionary notes, if you’re ready to brave the software, proceed. We love the program
on a windows tablet, and RL routinely uses it on a mac. So everything described here works flawlessly in
those environments. It is also reported to work very well in most Unix environments.
NOTE
As of the publication of this manual, the current version of QGIS –2.4 has several bugs that are annoying
enough that we do not recommend using it as a field platform. Instead use QGIS 2.0 or QGIS 2.2.
Because archive editions of 2.0 and 2.2 can be difficult to find the web sites for windows and mac are:
MAC http:// http://www.kyngchaos.com/software/archive
Windows: http://qgis.org/downloads/.
Getting Started
General Statement on this tutorial:
Most of the basic operation of QGIS can be found in the online documentation, or a .pdf that can
be downloaded. It is a reasonably good manual, with a lot of different parts, including developer’s tools
if you are so inclined. As of this writing, the link for these resources is:
http://www.qgis.org/en/documentation/manuals.html
For this tutorial we do not have time to go into all of the details of qgis, but will simply emphasize
the parts that are most relevant to field projects.
QGIS 2.0-2.2: The developers of QGIS made a major change in the software in mid 2013 when
they released v 2.0. The features used here were developed for a previous version (1.8) and worked
flawlessly through version 2.2. Unfortunately the QGIS developers changed the program slightly in
2.4 and our custom data entry forms no longer work properly. We have reported this bug, but as yet
is has not been fixed. We will update this tutorial when this bug is fixed. Until this and other bugs are
fixed we suggest using versions 2.0 or 2.2.
QGIS basic setups for field geology: If you are an ArcGIS user you will see many similarities
between QGIS and Arc, but QGIS is more limited in capabilities. For example, ability to make polygons
from lines is very limited (not a problem for field applications where you shouldn’t be doing this
anyway), many of the fancy GIS capabilities of Arc are limited or nonexistent in QGIS, editing is primitive
relative to the most recent versions of Arc (10 as of this writing), etc. Conversely, this is not necessarily
bad for a field tool, and this is where the goldilocks factor arises. There are none of the deeply nested
menus of Arc (2 clicks will do anything) and there is no “dreaded red toolbox” where there is some
valuable tool that you’ll never find unless someone tells you about it. The equivalent of the “red
toolbox” in QGIS are plugins that are available, and you’ll have to search the repositories for plugins to
see if something fits your needs. We suggest a few of these useful plugins later in this tutorial.
3
Basic Geology in QGIS:
Step 1. Create a working folder for your project.
We have already done this for you for this tutorial, The structure we have found most useful is to
have: (1) A project folder this will contain everything related to your project. Topographic maps, soils
maps, images, seismic line locations etc… When we have projects covering large areas, we have found
that it's a good idea to create subfolders with imagery, topographic maps etc… Within your project
folder, create a shapefile folder. The easiest way to do this is to copy our project folder from the
course materials and to rename it. Be sure that the shapefiles are in the correct projection for your
project. (We’ll show you later how to change shapefile projections.)
Step 2.
Start QGIS
Run the program, not the browser, which appeared in QGIS 1.8 as their attempt at ArcCatalog. The
QGIS window should look something like this if all the bells and whistles are running (we won’t use all
of these for field aps)
4
You will not need all of these for field applications. The only ones you’ll really need are the edit
tools (black arrow), the zoom tools (orange arrow), and the attribute toolbar (red arrow). You might
also find the file menu useful (blue arrow) since you’ll need to be saving your project a lot and the save
button is easier to hit than pulling down the menu. You might also find the add data toolbar (fussy
blue elbow arrow) but we usually close it after an initial project setup because menu’s can accomplish
the same task. For all field projects you’ll also need to add the special gps window. To toggle these
buttons off, pull down the view menu, and go to the panel and toolbars submenus where you can
toggle them on and off with check boxes.
Step 2.1. Set the Datum and Projection for your project.
This step is optional, but a good practice. As an alternative you can always make sure your shapefiles
are in the right projection before you start, then add them first, then the project will assume this
projection by projecting on the fly. (This is a double-check procedure to avoid potential problems)
2 .1a Select File Menu  Project Properties. This will open a window that looks like this….
2.2 Select The Tab labeled Coordinate Reference System, which provides a display below.
Check the box labeled Enable ‘on the fly’ CRS transformation. (this may already be checked, but
it is important that this be checked)
5
While not necessarily
essential, this will reduce or
eliminate a lot of potential
problems. Alternatively, you
can load a file with the
coordinate reference you
want first, then make sure
the "enable on the fly CRS
transformation" button is
selected. This is similar to Arc
(first file loaded rule) but can
be confusing. The program
will project anything loaded
into the coordinate reference
of the first file. A Best
Practice is to Make sure your
shapefiles are in the correct
projection and load them
first.
2.3. Save your project.
IMPORTANT NOTE: Remember QGIS is like Arc in that the project (map) is just the pointer to your
files and gives commands for how to draw things. Thus, saving the project only saves the graphic
information. Saving data requires saving the data files (see below) Nonetheless, here you’ve
started doing those setups, so save the map somewhere you can find it (we always put it in the
same folder as the data—the “workingfolder” you created earlier and that is a known, foolproof
method).
6
Generic Mapping Project in QGIS
You will be using a generic project here that also works in arcpad. QGIS won’t be able to use the
arcpad layer definition files ( the .apl files) but shapefiles are shapefiles and in QGIS we’ll use a QT based
form (basically an xml file) with the extension ”.ui” or shorthand for user interface file and a layer
definition file we’ve made for you. (for details on arcpad, see the arcpad tutorials at this website)
The first thing you should do is go to your tutorial folder, find the folder “newgenericproject_2D”,
open it, and copy the “shapefiles” folder into your working directory for this project (we suggest using
the “workingfiles” directory you set up earlier). Eventually we want to move to a data structure that is
less primitive than shapefiles, but they have certain advantages. If you are not familiar with shapefiles,
take a moment to look at the data structure. Shapefiles are actually a group of files with the same name
and different extensions. It is very important to understand, with shapefiles, that ALL of these files are
essential, although some are more essential than others. The actual data reside in the .shp file, but the
file will be unusable without the accompanying .shx .sbx .sbn and .dbf files. The .prj file is essential,
but can be reconstructed (if you’re lucky)—this is a projection file, and can be rebuilt if this file is lost,
and you know the projection! The .apl file is strictly an arcpad file and can be eliminated in qgis (it is an
arcpad layer definition file). The .dbf file is potentially useful as a standalone file (copied and then
opened in excel) because it is a simple table of the attributes—e.g. it is a great way to extract your strike
and dip data, etc., for other applications. When dealing with shapefiles, the safest way to deal with
them is to always move or copy entire folders that contain your shapefiles, to avoid corrupting them.
While looking at these files, note the data structure. There are many alternative ways to set up this
data structure, but we have used a compromise between display and data entry. Our point data are
split into several point files rather than a single “station” which might be more familiar. This approach is
arbitrary, but is something we have found convenient to speed up field operations (for example,
separation of elements that are not always recorded at every station). If you don’t like this, you can
always revise this data structure to your needs (see later descriptions in this tutorial). Similarly the line
elements of this project are divided into the four types of lithologic contacts for geologic maps
(depositional contacts, unconformities, intrusive contacts, and faults) as well as structural elements (fold
axial traces). If you look at the metamorphic project (also on this website), there are other line elements
included there with a distinctly different data structure. Again, this is a tradeoff in field efficiency in that
we have found this approach is faster than using something like “contact” that then required further
attributes to describe it as data table fills. Your choice if you want to change that, but we’ll follow this
data structure in this tutorial.
If you have worked with Arcpad before, or are doing this tutorial after doing the Arcpad tutorial,
you will see this is the same data structure we use in our arcpad project. The setup is different in
arcpad, however, as is the workflow. Again, like arc, the map will be just a pointer to the data
(shapefiles) so it is the shapefiles that are important to backup. Also ,the default map projection will be
the same as the first data file you load and if you check the project on the fly box, everything should load
fine.
Step 3. Load and manipulate a raster file.
NOTE: Although you have already, theoretically, set your map projection above. It is best to first add
a raster layer that is in the same projection as you want your project to be. That will avoid any
problems like the program defaulting to a map projection you are not expecting.
7
3.1 Either select the Add Raster Layer button (right),
or select Layer Menu Add Raster Layer
Navigate to the Generic Mapping Project folder and add Sfranklintopo.tif
We have discovered two manipulations that are particularly helpful for field mapping.
These are changing the transparency and enhancing contrast and colors.
3.2 Manipulate image transparency.
Either double click, or control click or right click on the layer name in the layers panel and select
Properties.
This will open the Layer properties window. The transparency tab is the third one in QGIS 1.8.
Play with changing the transparency. This allows you to superimpose different images(e.g.
topo contours on an orthophoto) and it can help you see your linework on a background image
(particularly on DRG topo maps)
3.3. Manipulate raster color contrast. This is one of the key benefits of itegrated GIS mapping in that
imagery can be “improved” do display different features
Open one of the photographs in the generic project. Try l3106_13_1_nc_21092008. An image
should appear, covering the topographic map. You can play with the transparency and look at how the
topography matches the geology in the photograph . But first, lets better differentiate the layers.
8
3.3 a Open the layer properties window by double clicking on the layer, but instead of
selecting the transparency tab, select the Style tab on the left. There are numerous ways of changing
the image, but most are ineffective in enhancing geologic contrast. A simple way to play with enhancing
contrast is to stretch the color contrast
3.3.b On the drop down menu near the bottom of the style tab, change “no stretch” to
“Stretch to MinMax”. Check the “Use standard deviation” radio button. You can now play with the
value in the box to the right. Lower values enhance contrast. For this image, 2.5 to 2.0 work on my
screen, enhancing the color differences of the different units. (Note: If you are arcgis user, this will look
familiar. It is a big advantage over arcpad though, where you do not have this control.
STEP 4. Load and Set Styles for Shapefiles and other Vector Files
Loading Shape files is similar to loading them in ArcGIS, but there are extra steps that are
required in order to have them display properties you might want on a geologic map. First, let’s load a
shape file.
4.1 Select Add Vector layers from the button or the Layers menu. Navigate to QGIS Generic
Project folder and then to the shapefiles_genericproject folder. Notice that in QGIS, there is a
dropdown menu in the bottom of the file selection screen that allows you to load a wide variety of files,
including KML files from Google Earth. If all of the files are grey, select shapefiles from the menu at the
bottom and then select depositional contacts from the list. Only the .shp files should be highlighted,
although sometimes all the subfiles appear (no idea why). Select all of the shapefiles in the folder, and
load them. Holding down control key allows multiple file selection.
4.2 Right click on the name in the layers list and select properties. As with Raster images, this
is where we can set file display properties.
You should now have a screen that looks something like the image below. The colors will vary
because this is a random assignment of styles. You’ll see all the shapefiles to the left in the legend
(layers window). There are two useful windows at the bottom, the one labeled “coordinate” gives a
readout of the location of the cursor on the map (in map earthcoordinates, so this is utm), and the map
scale is next to that. So you can change the map scale with this tab—very useful.
4.3 Re arrange data layers. Arranging data layers is easy, simply drag the layer to the position
you want it in the layers panel. We usually put all of imagery at the bottom and the shapefiles on top in
order to see the shapefiles. In the field, it also helps to use a standard order, (for example, point files
like stations and orientations on top) If you’re not using all the shapefiles, or some you use rarely, you
can either remove them or put them at the bottom of the layers.
9
10
4.4 Set line and Point Styles. When you get the layers in the order you like, double click on the
“depositionalcontact” layer (or right click, and choose properties), and you should get this big dialog
box. .
We have set up some “easy-to-use” files that you can adapt to easily apply line styles. While not
difficult to do, it can be a little tedious to create your own styles. On the other hand, adapting the
files we provide is easy and, as long as you save under new names, you can always re-use the
originals. To use our examples:
4.5 Find the button in lower left, Load Style, and activate that button. A standard file dialog box
will appear. Navigate to the Layer Definitions folder in the Generic project folder and select the
depositionalcontact.qml file.
The window layer properties dialog box should now show the new styles, keyed to the attribute
“quality”. Close the dialog box and your map should now look something like this:
11
Note how the line styles have now changed for the first row of lines (blue arrow above)
4.6 Note that these line files are attributed with a “quality” and that attribute is key to setting up
the linework. You can set this up any way you want if you don’t like our setups, but we’ve provided
some pre-made style sheets and forms, which we’ll add now. (unlike arcpad, you are encouraged to
experiment with line styles here, it is rock solid stable so feel free to change these on the fly in the field as
needed. For example, we often find a colored line is easier to see on aerial photography bases vs black
lines, like here, which are easiest to see on a drg topographic map)
Step 5. Loading forms for data entry
Select the Layer Properties by double clicking on the depositionalcontacts layer as we did
before. This time select the Fields tab. It should look like below.
12
You'll need to pull down the "attribute editor layout" tab (arrow above) and in the pull down menu,
select the "provide ui-file" tab. Once you have that toggled, the upper right corner of the properties
dialog box will look like this:
Now you hit the well hidden button (arrow points to button with 3 dots) and browse for your ui form.
Note that 2.0 is as stupid as 1.8 and will default to another folder, but in 2.2 this seems to be solved.
Find the forms folder (in your tutorial folder) and select the depositionalcontact.ui file. When you
return to the properties dialog, hit ok and we’ll be back to the map.
5. C
NOW WE MUST TEST OUR FORM!!
Turn editing on for the layer. Make sure the layer is active by selecting it. Then find the little “pen”
button in the edit menu: (black arrow below—when editing is not active, everything else will be
grayed out, as below).
13
Activate editing by clicking the pen, and the other tools will become colored, meaning they are active.
If the editing is not behaving as it should, the problem is usually that you have selected a different
layer in the layers menu. For example if a raster is selected, then there will be no response to the pen
tool.
Now, let’s test our form. Click the “add feature” button and you will be ready to draw a line.
Then start drawing something.
freehand line.
This is a standard “click click” tool—there is a plugin if you want a
To finish the line in QGIS you must right click, or if you are on a tablet it is usually a press and hold
(easy with a stylus, hard with a finger. There are machine setups that vary this, depending on your
hardware—e.g. mac which lacks a right click). On Macs, a Right click on a mouse-pad, or a control click
will end lines. There may be options in qgis for this that we don’t know how to change too).
But hopefully when you right click, you’ll now get a nice data entry form pop up like below:
14
The black arrow (on the map) shows the line I just made and the dialog box is the form ready for
data entry. The first two fields have pull-down tabs to fill these attributes. The first one (red) is where
you tell the program how to draw the line—the conventional solid vs dashed vs dotted vs spectulative
contact. Choose one of these other than exposed. The second field (orange arrow) is “contact type”
where you can select Formation boundary, bedding trace, volcanic contact—you can change these if you
wish. The last one (green arrow) is a freeform note field. We consider this an essential field where you
can add valuable information about any contact; for example, you might indicate every point was
located with GPS vs projected through the woods as a guess vs etc. So here is an example of the form
filled out with speculative volcanic contact, and no note yet added—NULL will be the default.
Note: the red x’s are anchor points for the line—these can be edited.
To make sure your form works, open the attribute table for the depositional contact layer (right click on
the layer pulls down this option), mine looks like this:
15
The blue arrow shows the attributes for the line I just made, the red arrow shows one that had a
problem (hopefully you won’t get this)
5.D Assignment 1: Repeat the operation of loading a layer definition style and form for each of the
data layers except orientations (we’ll do that separately). Don’t do any new editing yet, just do the
tedious part of linking in all the forms and layer definitions.
5.E VERY IMPORTANT—fix widgets in Orientations data entry
The orientations layer is the one you will most frequently use, but it is the one with most potential for a
problem. Hopefully when you “load style” this will work flawlessly, but if it doesn’t you’ll need to follow
these steps:
Step a: load svg graphics where qgis can find them.
The tutorial contains two alternative layer definitions, one that uses esri fonts and another that uses svg
symbols. The ESRI fonts are there, but don’t use them. There is a bug in qgis 2 that doesn’t properly
rotate font symbols, so we have to use svg graphics. (easier anyway since you can modify, or make your
own, from many standard graphics programs). To begin, use your file browser to locate the folder in the
tutorial folder with path … /tutorials/QGIS/newgenericproject_2D/Geologysymbols Copy the whole
“Geologysymbols” folder to the clipboard (or open a new window so you can drag and drop), then
find the program file for QGIS. On a Windows system the path is typically C:\Program Files\QGIS____
(the ___ is the name of the version, in 2.2 this is Valmiera). Now dig down into this folder following the
path:
/apps/qgis/svg.
On
a
Mac,
the
folder
should
be
/Applications/QGIS.app/Contents/Resources/svg/. You should see a series of folders that contain svg
16
graphics files within them. Paste the “Geologysymbols” folder into this svg folder. The window should
look something like this (assuming you’re in windows, will be different in linux or Macs version of linux)
Step b: Fix the widgets
To make the forms work properly in the orientations shapefile you will need to change the widgets in
the data entry fields. This accessed in the fields tab of the properties dialog box. So right click (or
double click) on orientations, and you’ll get the familiar dialog box:
17
If your style has loaded properly, your “edit widget” tabs will look like this. If not, they will
show the default fields “line edit” in all of the fields. Unfortunately “line edit” won’t work
because the program is expecting a number, and a number requires a range statement. So if
this field shows “line edit” hit the button for “strike” and you should get something like this:
18
Select the “range” widget and the box will change to this:
19
a. Change the values in all the fields to the values shown above—note, this is the range of
azimuths from 0 to 360.
b. Repeat this operation for the three rows DIP, TREND, PLUNGE (of course, for DIP and
PLUNGE the range will be 0-90 and for TREND it will be 0-360)
Now your fields dialog box should look like the one at the beginning of this section; with edit
ranges and line edits filling the specific fields. You should now be good to go.
BUT, before you go farther, make sure you are properly entering data in all the fields. Make the
orientations layer editable (same pen button) and enter some fake numbers. Try these:
Now open the attribute table (right click on the orientations layer) and make sure the data filled
the appropriate fields. If it didn’t, double check you have all the tabs right, you’re added the
right data layers, etc. If that doesn’t work, check with the authors and we might be able to help.
(note: this is one of the things that DOES NOT WORK IN 2.4. So if you’re using 2.4 we will
know immediately why this doesn’t work)
When you get all these forms and layer definitions linked, your map should look something like this.
20
Now, save your project! Give it an appropriate name for your purposes. We highly
recommend you save it in the working directory folder because that way you can make a copy
of that folder and still open the map without having to redo all this!
Final Note on Setups: In QGIS once you have set up your project, you will want to keep your map
setups the same. So it is best to do all your data entry and edits in the same working directory. At the
end of each field day, or when finished with edits, make a simple backup by copying the shapefiles
into a backup folder; e.g day 1, day 2, etc. Most people find this pretty intuitive because it is a simple
backup copy process. If you do edits at night you can just directly edit the working directory after you
make the backup. Alternatively, if you are using a different computer for editing you can copy the whole
working directory (with the project map file) to the other computer, do your edits, then copy back to the
field computer, overwriting the working directory. Be a bit careful with this workflow, however, in that
it could generate a disaster—i.e. make sure all those files are backed up BEFORE you do this.
Aside—alternative data structures: If you go to the digital mapping website:
http://www.geo.utep.edu/pub/pavlis/digitalmappingwebpages/
There is an alternative set of shapefiles that you might prefer to the ones described here. They
are located under the downloads tab. They include this project, a similar project with 3D
shapefiles and a slightly different data structure, and a metamorphic project. The setups are
similar to those described above, but some of the files may have issues with the fields setups
(you can refer to the fields setup issues described above). In these projects the station tables
and other point files are a little more elaborate. For example, the station table automatically
21
captures date and time, the photo file has a field for recording the direction the photo was
taken, etc. Don’t use these files if you have a small screen device (phone size) because the
forms will be too big for the small screen. The metamorphic project also is quite different. It is
set up for working in metamorphic terranes where you are mapping form lines for different
metamorphic foliations, and the point files contain more extensive options for measurement
types and symbology. Both of these have been thoroughly tested as well, but don’t mix the
projects unless you become very comfortable with the software—you could run into problems
doing so.
STEP 6. Entering data and Editing Points and Lines in QGIS
Exercises: Now that all your layer definitions are defined and forms loaded, experiment with
entering data for some of the data layers. Take about 5-10 minutes for this.
Exercise 1—Data entry: Play with the program
Before adding any background maps, experiment with using the line data layers in this generic
project. If this is an in class tutorial your instructor will go through examples, but before moving on you
should work with all or most of the line layers, and with one line for each quality attribute to see the line
style, etc. The key thing to understand is the workflow which can be counterintuitive: select the data
layer appropriate for the object you want to draw (e.g. I want to draw an unconformity line), decide
ahead of time what the quality of the line is you want to draw (e.g. would this be a solid line, dashed,
dotted, or queried line), draw the line, right click (or click and hold for a tablet), fill in the quality field
for the object (which you had already decided before starting to draw the line), fill in any of the optional
fields you wish in the form, hit ok. The line is drawn.
When you finish drawing some lines experiment with the point object files. Note that in the
orientation shape file, all orientations are strike and dip, right hand rule AND you must pull down the
data type tab and select what it is you’re plotting! If you do not select a data type you will get a default
(probably bedding) and that may not be what you want! Also note that this data structure may not be
to your liking, but can be easily changed (see some suggestions below).
VERY IMPORTANT; MUY IMPORTANTE! There is no autosave in QGIS!
In programs like arcpad there is an idiot proof autosave feature (which can cause its own problems, but
that isn’t the issue here). In QGIS you must save all data entry or edits after completing the operation,
or nothing happens! Fortunately this is simple (and simpler than Arcmap, which has a similar issue if
used as a field tool). Note the little floppy disk icon in the edit toolbar, just hit that button and your
data are saved. THIS ONLY APPLIES TO THE PRESENT ACTIVE OBJECT! That is, don’t think this saves
other shapefiles, this must be done individually for each layer! Similarly realize that saving the
map/project DOES NOT save the data—only the save button on each layer saves your edits!!!!!
Bottom line: develop a workflow where as soon as you finish any data entry, or edits, on a given layer,
hit the save button. Get in the habit of hitting save on a regular basis to prevent data loss.
22
Exercise 2—editing
Basic editing: This program would be pretty useless for field geology if you couldn’t edit your work.
Editing is straightforward, similar to drawing programs. All you need to do is make sure the layer is
active (selected by clicking on the layer) and that the editing menu active (selecting the pencil). Then
instead of selecting the point or line entry button, you select the edit lines button (see figure below—
black arrow points at the button). Work with the fake data you worked on in exercise 1, editing objects
you created, etc.
Other editing: some useful tips that aren’t easy to find in the documentation
1) Delete entire object: A times you may want to delete an entire object you drew because it is easier
to just start over. QGIS does this a weird way but it is because you can select objects via the attribute
table or graphically and it gives you an option for working on multiple objects. To select an object
graphically, you use the pulldown menu indicated with the blue arrow on the figure below. Selected
objects turn a default color, usually bright yellow. Experiment with this. To delete an entire object, you
select the object(s) then a button in the edit menu (orange arrow in figure below) changes from grey to
red (not good for color blind but still resolvable). Hit that button and it goes away. Alternatively, just hit
delete on your keyboard (on a mac—this doesn’t seem to work on windows).
23
2)
2) delete vertex: select the vertex, then hit the delete key (somewhat painful on a tablet without a
keyboard—you’ll have to activate the onscreen keyboard before you begin the edit);
3) add a vertex: put cursor over the place you want a new vertex and double click (even more painful
with a blunt digitizer like your finger on a touch screen tablet—best to either get a mouse for these
devices for this type of operation, or get a tablet with a pen interface)
VERY IMPORTANT: Like data entry, if you want to keep your edits, you hit the little icon that looks
like a floppy disk in the edit menu.
Exercise 3: Something a little more realistic
Preliminaries: Ok, now you know how to use the basic tools, let’s try doing some geologic mapping
using high resolution aerial photography. If you haven’t already done so, please download the arcpad
tutorial from the digital mapping website:
(http://www.geo.utep.edu/pub/pavlis/digitalmappingwebpages/)
and move the raster map files from that tutorial to your working directory for this tutorial.
Pull down the layer menu, and select add raster layer. When the file explorer dialog opens, follow the
path to the arcpad tutorial files you downloaded, and find the folder:
Tutorials/arcpad/imagery_inclassexercise
And add the two images. One is a topographic map, the other is a georeferenced google earth image.
(if you want a lesson on how to georef google images, let the instructor know if this is an in class
24
exercise, we can do that later in the day if time permits. Otherwise contact us. This can be done in
QGIS or ArcGIS whichever is most convenient for you)
We already did something similar to this earlier in the tutorial, so just manipulate the layer order and
transparency as you did earlier. Presumably you’ll have a partially transparent topo map on top of the
orthophoto base.
Hint: If you don’t see the images, they are undoubtedly not in your view because of the zoom position
you are in the map. To display the area with the raster, select the data layer you want to see (e.g.
franklintopo) and right click. In the pop up menu, select “zoom to layer extent” and the view should
zoom to the area of interest.
Data entry with background map: Zoom to the area around McKelligan canyon (southern half of the
map where the quarries are) and your instructor will give you some guidelines for drawing some lines
interpreting the geology. You will need to turn layers on and off a bit, work with transparency, etc;
whatever works best for you. Nice thing about this area is all four types of geologic contacts are present
in the area, so you can practice drawing all these line types (sorry, no folds, but you can play with those
symbols on your own)
Also, please do some strike and dip estimates to practice entering orientation data. You can also
practice three point problems if you’re so inclined since these units v in and out of terrain, etc.
Have fun…
ADDITIONAL GOODIES. PLUGINS
Quatum GPS has a variety of plugins that can be used for various tasks. The use of plugins dramatically
expands the ability of QGIS beyond the basic mapping functions. Plugins are easy to install when you
have an internet connection. Simply go to the Plugins tab on the QGIS main menu and select manage
and install plugins The QGIS website has thousands of plugins, most of which are specific for tasks not
relevant to geologists, but they are fun to browse through. The ones we have found most useful for our
work are, in order of frequency of use.
MmQgis allows merging of shapefiles, for example from different geologists working on the same
project. It has other useful shapefile tools.
Digitizing Tools – The most useful features are the prolong line tool, which adds a utility the absense of
which was an annoyance in early versions of QGIS. It also provides split polygon and line tools.
Join Lines – This allows you to join segments that you may have mapped from different locations.
XY tools allows you to import Excel and other spreadsheet files and to export shape files that include the
X and Y coordinates. This is much easier than trying to get X and Y coordinates from ArcMap.
25
Qprof -- one of our favorites. Using a DEM loaded into QGIS, it generates a topographic profile for
plotting cross sections along a line from a shape file or selected interactively. Can be scaled to 1:1.
Qgsurf -- another of our favorites. The most useful feature here is a “ 3-point”tool that allows you to
make three or more clicks on a photo or mapped contact and interpolate a strike and dip from an
underlying DEM. Another tool takes intersections and orientations from shapefiles and plots projected
geologic planes. It takes a while to learn but can save time with long and complicated cross sections.
This is great for when you are doing “virtual geology” of inaccessible areas.
GEarthView– A click of a button launches Google Earth and places your data into Google Earth where
you can save it a kml.
Freehand Editing – A must for frequent tablet users. Allows freehand drawing of lines.
Ftools – for analysis and editing of shapefiles
Gdal tools – for analysis and editing of raster images.
For Specific Tasks and Advanced Users
Contour Plugin -- Creates contour and filled contour maps from scattered point data. Good for isopach,
percent of rock type or facies and so many other things.
Google Maps Engine Connector.
For Geodesists, Paleocurrents and Structural Geologists, Vector field renderer. Creates lines or arrows
showing the magnitude and direction of vectors from point data, for example plate motions or
paleocurrent indicators.
IN DEVELOPMENT
As of this writing we haven’t yet perfected this, but should soon have the ability to draw lines based on
multiple attributes; e.g. thrust fault with a different symbol than normal fault. It is a “small matter of
writing a little computer code” to make this work in QGIS, and it isn’t perfected yet. Similarly we think
(but haven’t tried it yet) that we can solve the dual-plotting problem of orientation data. That is, if you
make a planar measurement and a linear measurement from the same spot (e.g. slickenline on a fault
plane) we can’t yet plot these together. We’re pretty sure we can solve this, but give us a few weeks to
get it working!
26
GETTING READY FOR THE FIELD
QGIS can have a few issues in the field if you go unprepared, so a little preparation and care can
save a lot of trouble. The biggest issue is make sure you are communicating with your gps device
BEFORE you head to the field!
PART 1. Modifying the Display.
STEP 1: If you haven’t already done so earlier in the tutorial, turn off most of the buttons
As we noted above, for field work we generally uncheck everything but digitizing, attributes, and
map navigation (+/- file if you want a button to save the map).
If the Android version of QGIS ever gets perfected, this step will be essential on something like a
phone. For a tablet it is less of a problem so you can also keep things like vector and raster, although all
of these can also be accessed from the menu bar. Aside: unfortunately, to deactivate or activate a
toolbar you have to do them one at a time, you can’t just check off all the ones you don’t need at one
time. On a touchscreen tablet, this can be very annoying if your poor digitizer (finger) hits the wrong
button.
PART 2. USING A GPS
A Note on GPS issues and Windows 8
Most people will probably use this program with a windows 8 tablet. Windows 8 is a wonderful
platform for a field computer, but it really really sucks in one regard—Microsoft did not build in drivers
for GPS devices into Windows 8 tablets. What that means is even if you have a computer that has a GPS
built into the board (e.g. our 8” asus tablets) the OS doesn’t know it exists. There is a lot of internet
chatter on this subject and we haven’t been able to sort it out. So our solution has been use external
GPS units, linked via Bluetooth. If you are a mac or linux user, and want to take your laptop or tablet out
in the field, this section is irrelevant. However, for windows reader this is a must read section!
There are several gps units out there that use Bluetooth connectivity. They range from submeter
high-end units through gps/glonas devices with super-fast lock on (e.g. Garmin glo unit) to cheapy units
that sell for as little as $30. All connect via the Bluetooth manager in windows 8, which is accessed
either through the control panel or on the desktop from the taskbar (depending on how you set up your
device). Bluetooth should be plug and play, but in windows 8 it is always plug and pray. Here are the
known issues that are very very important to know to use these Bluetooth GPS devices:
1) When you have your device ready for pairing to your computer stop a minute. Make sure you
have the pairing code for your gps device. Many times manufacturers don’t even provide this number
out of the box because most systems, other than ^%$# Microsoft, don’t require it for this type of device.
For some reason, however, Microsoft forced this requirement in windows 8 (note, windows 7 is actually
worse in that some devices can get by without it and others don’t, it is totally unpredictable as near as
we can tell) In any case, if the manufacturer does not provide the pairing code out of the box, you can
27
undoubtedly find it at their website, or you can just try a few known pairing codes. For example, a lot of
devices use the spaceballs code: 1234. A lot of others use 0000. So you might just try these if you can’t
quickly find the real code.
2) Once you find the pairing code (or if you want to be brave and use the google equivalent of “I
feel lucky” and you’re willing to try the generics ) go to the Bluetooth manager on your computer. Hit
the “add a Bluetooth device” button.
3) the pairing screen comes up. It may take a few seconds, but your device should appear. If it
doesn’t make sure Bluetooth is on both on your computer and the device. If you don’t see it, you are
into a windows problem. (maybe restart both devices???) Normally, however, once you see the device,
click on it and hit “pair”.
4) the computer will flash a few things, and it will ask for the pairing code. Enter it now (and do so
fairly quickly, it will time out if you hunt around for a minute trying to find a slip of paper)
5) Once you enter the code, follow the directions to finish the pairing. Now is where it makes no
sense. If you watch the Bluetooth manager come up, it will probably show the device paired for perhaps
5-10 seconds. Then it will say it is not paired. This is a lie. It will never show as paired again, even
though it will, generally, always pair as soon as both devices are on. This is a windows bug, and
hopefully it will be fixed in later windows versions. But in the latest version of windows 8, it is still there.
6) close the Bluetooth manager, and leave your gps on. Proceed to QGIS to make sure the pairing
worked (it usually does—if something fails, good luck; try the usual starts, restarts, etc. The gps should
repair with the device every time they are both turned on—don’t repair unless it is absolutely necessary)
NOTE: This sounds like a pain, but really you should only have to do this once. Now you are ready
to use the GPS on your device.
Using GPS with QGIS
To use a GPS in QGIS you go the view menu, pull down panels, and select GPS. When you do that
the default screen should look like this.
28
The default position for the panel is locked to the area below the layers menu as shown above, with
the blue arrow above. To get started, you might undock the panel from this position (grab the bar at the
top and drag it to the screen) to see the different parts of the window (default screen is below)
There are four subpanels that can be activated with the buttons on the upper left that can give you
information when the GPS is active. The leftmost button gives you a raw position table (readout of lat
long and various GPS info in tabular form. If you click the little histogram (second from left) you get a
signal strength graphic (when the GPS is active), if you click the little bullseye (third from the left) you
get a skyplot of satellites being tracked by your device, and the right button is the default screen, GPS
tools (the icon is supposed to be a wrench). You may or may not need these, but that is what they are.
Now comes the time for a few genuflects, bowing and scraping to the computer gods, or maybe
just plead to the demons of Microsoft. Hit the connect button.
If everything is in your favor, in a few seconds the “connect” button will turn to “disconnect”
indicating the gps is connected Don't let this fool you into thinking you have failed to connect to the
GPS. At that point you can view the sky plot to see how many satellite you are tracking, the signal
strength, etc. You should also see the cursor appear on the screen at your location (the symbol size and
color can be changed if you wish). If your device connects, it should do so every time now, with a similar
pause of a few seconds for the connection.
29
Cautionary note on GPS: We have found that bluetooth GPS devices have a flaky feature that can
cause havoc if you are not aware of it. If you leave the gps connection active after you finish an editing
session, and put your computer to sleep, there is a high probability you will have serious problems. In
arcpad this commonly would cause the program to freeze, requiring a program restart. In QGIS the
crash doesn’t seem to be this serious, but it does cause things like inability to reconnect the device or
other unpredictable things. Usually if you simply exit the program and restart you’ll be ok; but you
might literally have to do the classic windows reboot to recover. So bottom line: ALWAYS GET INTO
THE HABIT OF ONLY LEAVING THE GPS CONNECTION ACTIVE WHILE YOU NEED IT. AS SOON AS YOU
FINISH, DISCONNECT!!! You don’t need to turn off the GPS. Then just hit connect the next time you
want a position, and everything should go find.
Other caveats: A strange bug appeared in QGIS 2 that persists to 2.4 and we do not know when it
will be fixed. On the GPS Information window you will see a button “Add line” (if a line file is active) and
“add point” if a point file is active. You would think this would work the way this feature worked in 1.8
(or Arcpad) which is to grab your GPS position (for a point) or a series of points (for a line). It doesn’t
work. Maybe we all need to complain to the QGIS developers about this problem? The solution is
straightforward here—you just use the GPS position shown on the map to locate your point (or series of
points as you move along it), but this is a lot slower than simply pushing a button. GRRR.
Finally, like any plug and pray issue, life is good if the GPS works, not so good when it doesn’t. Here
is some simple troubleshooting advice, depending on what kind of gps you’re using.
Option 1: try the usual windows start restart procedures. Not just restarting QGIS, restarting the
computer
Option 2: make sure your Bluetooth device is really connected—try re-pairing (not repairing) for
example. This might require deleting the initial Bluetooth pairing, then re-pairing. Annoying, and
unlikely to work, but always worth a try.
Option 3: real desperation is to dig into the windows control panels and make sure there isn’t
something messing up the Bluetooth ports. This can be a serious time sink, but worth a check?
Option 4: you might have to use another method to make sure the device is even connected. If
you have arcpad it has a very useful function that searches all available ports for a device that is
outputting GPS data. If arcpad can’t find it, it isn’t communicating—you might have device problem.
Another alternative is to use a terminal program this way, listening to each port—that is really doing it
the hard way though. Note, however, that if you do manage to connect to the device through another
program (like arcpad) that program may not release the port. So you definely need to exit the program
and you might need to reboot the computer.
Option 5: throw your device off a cliff (but you’ll have to figure out it if is the cheap gps our your
computer! (just kidding, no advice by this stage—you may need to try another device?)
GOOD LUCK!!!
30
Advanced , Setting up your own QT forms for Quantum GIS
(TP text, so if this confuses you, get in touch with him)
Quantum GIS uses data entry forms that are slightly different from Arcpad. The program uses user
interface (.ui) files that execute .xml code. I designed all of the forms here using an application called
QT Creator, but there are other ways to do this. I understand you can also use python to do this, but I
haven't mastered the snake.
QT Creator is a free online application, but if you really get into it, there is a pay version that is more
sophisticated. QT is the application that QGIS is wrapped in for the Android version, as I understand it
anyway.
Because QGIS is not a commercial program, it isn't surprising that adding forms and making them work
in QGIS is rather more involved than Arcpad with its Arcpad Studio Application. However, the good
news is, the QT Creator application is pretty friendly, and more versatile, than Arcpad Studio. Moreover,
I've made some premade forms for you, and they are very easy to modify in QT Creator (easier than
Arcpad Studio)
Just for fun, this is what the first few lines of the "stations" user inferface file looks like:
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>782</width>
<height>547</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>800</width>
<height>550</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
31
<x>530</x>
<y>490</y>
<width>169</width>
<height>27</height>
You can fiddle with this code if you want, but it is dangerous if, like me, your really don't know what
you're doing. So lets try something simpler.
Making a form in QT creator is a lot like Arcpad studio, you just need to know a couple tricks. Run the
application, and then open one of our forms (you can of course start from scratch, but it is easier to see
this way) Here is the screen for depositionalcontact.ui
32
On the left are various widgets you can use, on the lower right is the xml code, and in the upper right is a
summary of the objects in the form. We've used a combination of "combo boxes", "text edit" and "plain
text edit". Labels are just what they sound like--blank label features. The orientation.ui file also
employs a spin box--a somewhat annoying requirement related to forcing numeric fields.
33
Hopefully the widgets are self explanatory if you've gotten this far, the key is set up the form to the size
you want, enter the various fields, resize to make things fit, etc. It is basically a graphic operation, and
the program generates the xml code. The only time I had to ever fiddle with xml code so far was to
change things like "maximumSize" to avoid the forms going offscreen. One useful piece of information,
to change the values in a combo box field, you just double click on the object field, and you'll get a
popup window where you can enter the data. For example, under "contact type" in this example, you
might want to add something else like quaternary contact or something else you might want to
highlight.
These forms are generic and could be used for anything, except to make them work in QGIS you need to
set them up so they output the right data to QGIS. That means you have to tell it what the attribute
name is you want to fill. For our purposes, that is done with a link to an object name. So take the
example of the "Contact Quality" field in this form. If I right click on that field, I get a pop up window like
this:
Select "Change objectName..." and you get a new dialog box:
34
It appears here with the name "QUALITY" because that has already been filled in. For entering
something new you MUST type in the name of an attribute field you want to fill with EXACTLY THE FULL
NAME OF THE ATTRIBUTE FIELD! Note, it is very very easy to make a typo here; it is case sensitive and
spaces are recognized. If you have the slightest error, it won't work. So always check these!
When you like your form, save it (better put it somewhere else if you don't want to overwrite what we
made for you). simple as that--then just link it in, as described above and life should be good.
WARNING--ALWAYS CHECK TO MAKE SURE YOUR FORM WORKS, AND THAT IT IS RECORDING DATA! IF
THERE IS A PROBLEM, SEE THE TROUBLESHOOTING GUIDE BELOW.
35
Download