188.8.131.52. GPS and KML data, working with different coordinate systems
Other important functionalities of modern GIS are those to import and export GPS data (e.g. those acquired by handheld GPS devices), and the transformation between different coordinate systems. Because the GPS eXchange Format *.gpx is common and integrated within the OGR library (see section 7.3.2.), the import of existing GPS data is as simple as adding other vector data (see section 7.3.3.). Assuming that our point vector layer added in the previous step represents colony locations of honey bees we would like to locate in the field, this vector layer needs to be exported to a new *.gpx-file to be uploaded onto a handheld GPS device. This can be done with the same function used to save a layer to a new shapefile (Fig. 77), but modified settings:
- Right-click on the layer in the Map Legend.
- Select Save as.
- Choose the GPS eXchange Format (supported by a majority of GPS devices).
- Set the target coordinate system to “WGS84” (because GPS devices are natively working in World Geodetic System 1984).
- Enable the option Skip attribute creation (because we only need the coordinates for a stakeout of the colony locations in the field, without any attributes).
- Click OK and verify if the
new file (e.g. with the file name bees_colony_locations_WGS84.gpx) has been
created within the chosen destination folder.
Behind this two very important technical GIS functionalities are working: first, the translation from a source file format (*.shp) to a target file (*.gpx) format and second, a precise transformation between two different coordinate systems, even with different map units. If you have a software like Google Earth for instance, you can easily verify if the coordinate transformation to WGS84 worked correctly (if you do not have Google Earth installed, you can skip this paragraph, or download the software from http://www.google.com/earth/index.html).
- Open Google Earth.
- To open the *.gpx-file in GoogleEarth, go to File.
- Click Open.
- Browse to the location of *.gpx file.
- Beside the File name box, choose the Gps option from the dropdown menu.
- Click Open.
- The GPS data Import dialog window will appear asking if KML tracks should be created from the GPS data. Check the options Create KML Tracks and Adjust altitudes to ground height (with this function, all elements are attached on top of the elevation model behind GoogleEarth and you are sure that all features will be visible) and confirm with OK.
- Google Earth will do a file format conversion that results in a new temporary layer named “GPS device” in the panel Places > Temporary Places. The new created placemarks in Google Earth should be at the same location as in the QGIS project.
- Right-click on the layer GPS device.
- Click Save Place As to save
this temporary layer to the file system in the KML format (Fig. 78, make sure
to choose KML instead of the zipped KMZ format).
The Keyhole Markup Language (KML) is another file format supported by the OGR library. It provides great possibilities to share spatial information of vector based geodata with people who are not familiar with GIS software, since almost everybody can handle software like Google Earth. Of course it is also possible to import the KML file back to QGIS. We will see if the coordinate transformation from WGS84 back to the Cartesian CRS of Switzerland works fine:
- Just drag the KML file from its data source to the Map Legend in your QGIS project.
- By activating and deactivating the checkbox to the left of the layers
you can check if the geometries are congruent.
If there is a lateral shift between the point layers or an error in
scale, the option “on-the-fly” CRS
transformation was probably not enabled – you can fix this by navigating to
the main menu Settings > Project
Properties where you choose the second tab Coordinate Reference Systems (CRS).
Fig. 78. Save “Temporary Places” within Google Earth as KML-files to the file system.