GPS and GIS: A Great Combination, Part I
A GPS unit and a Geographic Information System (GIS) program are a great team. With a GPS receiver in hand, you can tap into the network of government satellites to calculate your position on Earth to within meters. With a GIS on your desktop, you can import acquired GPS data onto to your desktop and combine it with other geospatial features such as maps, aerial photos and satellite imagery. In this article, we will create a route with a GPS unit and import into the GIS program QuantumGIS (QGIS).
In the next article, we will situate the route onto a map and output the map for public consumption.
Plan a Fun Run, Make a Map
I love tinkering with my GPS unit, a Garmin GPSmap76S. I often carry my Garmin along with me to collect locations, or waypoints, wherever I go. I can then calculate distances between my home and those locations and between each other, even when Google Maps isn't handy. Also, because I am an avid jogger, I plot mile-long stretches around town, which I use to check my running pace.
Here is what my GIS unit looks like:
I also love exploring QGIS, one of the most advanced GIS programs for the Linux platform. QGIS is a free, open-source GIS program that is getting ever better and more popular. If you are new to GIS and want to learn more, you can check out my previous articles:
"Desktop GIS for Linux: An Introduction"
"Getting Started With Quantum GIS"
So, I have this GPS unit I love, and I've also been exploring and a great GIS program. Lo and behold, an opportunity recently arose to combine the two. I volunteer for a local non-profit organization here in my hometown of Lansing, Michigan, that wants to hold a fun run as a fundraiser. I immediately realized that I had the ideal toolkit for the job, so I volunteered for it. And rather than do it alone, let's do it together, shall we?!
The task of plotting the route for the fun run has a few criteria to consider. First, it must begin and end in front of the Michigan State Capitol building here Lansing, where I live. Second, it must utilize a stretch of a trail along the Grand River, which passes through downtown. Third, it must be 5 kilometers in length. And fourth, markers are needed for each mile so that runners can be given their split times.
Once the route for the fun run is determined, I will import it into QGIS and display the route on a map of the City of Lansing. I will then create an image of the map that displays the route so that my colleagues can get a visual illustration of what to expect. We'll do the latter 'display' tasks in a future article.
Take Waypoints, Create a Route
In order to achieve the above task, I need to do two things in 'GPS speak': collect waypoints and create a route. A waypoint is a geographical location that is defined by latitudinal and longitudinal coordinates, which one can gather easily using a GPS unit. A route is a series of waypoints strung together, which one also can do with the unit.
Our waypoints will be a series of key points along the fun-run route, such as the starting line, mile markers, turns and the finish line. In addition, we will also add a few extra waypoints where we are not moving in a straight line so that the distances are accurate.
Routes can be created either in real-time or after the fact. We will work in real-time, gathering each waypoint and immediately aggregating them into a route that covers the entire stretch. This will allow us to have real-time distance measurment, too.
In order to collect a waypoint on my Garmin GPSmap76s, I simply hold down a button labeled dually with the words "ENTER" and "MARK" for a few seconds. My GPS unit gives me a window that shows the waypoint's name, date and time of collection, geographic coordinates (latitude and longitude) and altitude. The image below illustrates the gathering of a waypoint.
Then, because I am building my route in real-time as I go, I add each new waypoint to a route that I've named "FUN-RUN". In order to add each waypoint to the route, on my Garmin I can simply hit the MENU button and select APPEND TO ROUTE. This action brings up a list of all waypoints in the route FUN-RUN and gives me total distance up to that point.
Here is what a route looks like on my GPS screen:
As I write this, I've just returned from the waypoint gathering process. I jumped onto my bicycle, Garmin in hand, and proceeded to create determine the path of the fun run. Measuring my progress was easy, as I utilized an option on my Garmin called the Trip Computer, which shows functions such as a trip odometer, overall odometer, trip times (stopped, moving and total times), current speed and average speed.
As I biked along, I followed the trip odometer, which allowed me to know my distance from the start, as well as where to mark each mile. As mentioned above, I 'waypointed' a number of other key points, as well. I journeyed through downtown and, as required, I spent time on the trail along the river. Then I finally made my way back to the Capitol to mark the finish line. As expected, I was unable to have the start and finish lines match exactly, though they certainly were close!
Now we have our waypoints, which are gathered into a 5 kilometer-long route called "FUN-RUN". Let's put this data into QGIS so we can display it.
Importing Data into QGIS
I am going to assume that you have QGIS set up and ready to roll. If not, please see my previous articles above for assistance.
If you have Garmin or Magellan GPS unit, then QGIS won't have any problem recognizing your device. Simply plug it into the UPS port. I had the problem that my Garmin is a bit older and thus has a serial port, so I used a USB to serial converter, which worked fine.
Before you do anything, you must install a program called GPSBabel, which does the actual heavy lifting in dealing with GPS data. Having Kubuntu Hardy Heron, I found GPSBabel in my Synaptec Package Manager and installed it without a hitch. If you need to go and find it, visit http://www.gpsbabel.org.
You obtain the GPS data from your unit using a plugin called GPS Tools, found by slecting Plugins -> GPS -> GPS Tools. Here is an image to illustrate:
Upon selecting GPS Tools, you'll obtain a window with 5 different tabs, as illustrated here:
Select the Download from GPS tab. In our case, we also make the following selections:
GPS device: Garmin serial
Feature type: Routes
Output file: FUN-RUN (Note: this is name of the file that will end on your system)
Layer name: FUN-RUN-layer (Note: this is name of the layer that will show up in QGIS.)
Then hit OK. This action will bring all of the routes en masse from your GPS into QGIS and create three new layers in the Legend on the left-hand side of the QGIS GUI: Fun-Run-layer, waypoints; Fun-Run-layer, routes; and Fun-Run-layer, tracks.
Here is what our screen looks like after importing the route Fun-Run-layer:
At first our route looks like just a tiny scribble in the Map View on the right-hand side of the QGIS GUI. While it shouldn't be a problem finding your route, you may have trouble if your GPS unit has many different toutes on it. If one is in Russia and other other in Rochester, then you may not be able to find the route you're looking for.
A few tips will help here. First, you should always use QGIS with a mouse-wheeled mouse, for this is the only easy way to zoom. Second, if you want to find your way within a layer, right-click on the layer in the Legend window and select Zoom to layer extent. This action will hone you in on key features within the layer.
GPS Data is Imported, Getting Ready to Map It
In order to keep these articles in digestible parts, let's set this task aside until the next installment. In this excercise, we have gathered waypoints using a GPS unit and aggregated them into a route, called FUN-RUN. We figured out how to get the program GPSBabel installed, as well as to use it to download route data from a GPS unit into the QGIS application. We also explored and utilized the GPSTools plugin in QGIS, which is our interface for GPSBabel. At the end of this article, we find ourselves with layers that display the GIS data in QGIS.
In the next article, we will find and load map files in the shapefile format in order to put our route into a context and see where it goes. After loading those shapefiles, we will produce a map that we can share with everyone so that they can see the route of our fun run.
Looking forward to seeing you in this GIS- and GPS-friendly space soon!
James Gray is Products Editor for Linux Journal
Practical books for the most technical people on the planet. Newly available books include:
- Agile Product Development by Ted Schmidt
- Improve Business Processes with an Enterprise Job Scheduler by Mike Diehl
- Finding Your Way: Mapping Your Network to Improve Manageability by Bill Childers
- DIY Commerce Site by Reven Lerner
Plus many more.