GIS Tips

This document contains notes and tips relating to Geographic Information Systems (GIS).

QLandkarte GT

Excellent client for managing GPS maps, routes and tracks. Also good for georeferencing tif images. The documentation is thin, but with perseverance, once you've figured out how it all works, it's a very good tool indeed.

Workarounds

Some tasks can't be done immediately, but the following workarounds get you the same end result:

  • To modify a route, convert it to an overlay, modify the overlay and convert back to a route.

  • To split an overlay, convert it to a track, split the track and convert the parts to overlays.

  • Track segments can be joined.

The most useful feature of QLandkarte GT is it's SQLite Database Manager which can be used to store Waypoints, Routes, Tracks and Overlays. It can be structured hierarchically, with branches that can be defined as a Group, Project or Other, which apply differenct rules relating to opening the branches recursively. This really helps when managing many GIS features and planning routes etc.

When importing data or downloading from the GPS, if the data contains identifying keys previously provided by QLandkarte GT, it is associated with the record in the database. Be careful if you have modified the data since the export as QLandkarte GT may not pick up the change (depending on the version of QLandkarte GT), e.g. moving a waypoint.

Note: QLandkarte GT is apparently no longer being maintained. QMapShack is being developed to supersede it.

Issues

macOS shows dialog boxes using the wrong language

This seems to occur when there is no translation for the desired languge and it defaults to the first locversion.plist file found under QLandkarte GT.app/Contents/Resources/, which is Czech. These resource files are created by ./MacOSX/mklocversion.sh script in the source tree during the build.

Presumably there is a bug somewhere in the Mac OS X implementation such that this happens with English. One ugly workaround is to create ./src/locale/qlandkartegt_en.ts with English translations.

See "Translation the Application Menu and Native Dialogs" in http://doc.qt.io/qt-5/osx-issues.html.

Cannot Create Map - All maps in a level must have the same projection

Run Qlandkarte GT from the command line with the -d debug option. When the maps are loaded, the projections used will be listed.

You can then use gdalwarp to create tiffs using the same projection, perhaps by copying one of the existing projections reported in the debug. E.g.

    $ gdalwarp input.tiff output.tiff -t_srs "+proj=utm +zone=10 +ellps=GRS80 +towgs84=0.991,-1.9072,-0.5129,0,0,0,0 +units=m +no_defs "

You can also clip the source images using pixel sizes with the -srcwin option to gdal_translate, e.g.

    $ gdal_translate -srcwin 913 999 7296 9103  \
    -a_srs "+proj=utm +zone=10 +ellps=GRS80 +towgs84=0.991,-1.9072,-0.5192,0,0,0,0 +units=m +no_defs" \
    input.tif output.tif

This example converts a geo-referenced PDF extracting a specificly named layer:

    $ gdal_translate -srcwin 913 999 7296 9103  \
    -a_srs "+proj=utm +zone=10 +ellps=GRS80 +towgs84=0.991,-1.9072,-0.5192,0,0,0,0 +units=m +no_defs" \
    --config GDAL_PDF_LAYERS "Layer.name" --config GDAL_PDF_BANDS 3 --config GDAL_PDF_DPI 400 \
    input.pdf output.tif

This example converts a geo-referenced PDF extracting all except a specificly named layer:

    $ gdal_translate -srcwin 913 999 7296 9103  \
    -a_srs "+proj=utm +zone=10 +ellps=GRS80 +towgs84=0.991,-1.9072,-0.5192,0,0,0,0 +units=m +no_defs" \
    --config GDAL_PDF_LAYERS_OFF "ALL" --config GDAL_PDF_LAYERS_OFF "Layer.skip" \
    --config GDAL_PDF_BANDS 3 --config GDAL_PDF_DPI 400 \
    input.pdf output.tif

Building On macOS

Extract the source:

$ tar -xvf qlandkartegt-1.8.1.tar.gz

Check the build and installation instructions:

$ more ./qlandkartegt-1.8.1/INSTALL

Install required libraries, e.g. if using Macports:

$ sudo port install libproj4

When using Macports, install gpsbabel with the qt4 variant:

$ sudo port install gpsbabel +qt4

Run ccmake:

$ mkdir build_QLandkarteGT/
$ cd build_QLandkarteGT/

Configure the build environment:

$ ccmake -Wno-dev -D QT_QMAKE_EXECUTABLE=/opt/local/libexec/qt4/bin/qmake ../qlandkartegt-1.8.1

When the configuration cache window is displayed, press 'c' to configure, then 'g' to generate the configuration. You may need to press 'c' a second time before the 'g' generate option is shown.

Perform the build:

$ make

Custom Waypoints

Visit https://github.com/sdennler/waypoint-symbols for artwork and instructions for creating custom waypoint symbols for Garmin devices. On Mac OS X the WaypointIcons folder is under ~/Library/Application Support/QLandkarte GT/WaypointIcons/.

Wikiloc

Wikiloc provides the ability to manually plot a track on the website using both OpenStreetMap and satellite tile images (amongst other map options).

You must be registered and signed in.

  1. Select the option to 'Upload trails'.

  2. Select 'Draw your trail by hand'.

  3. You can leave the search field blank and a world map is displayed which you can pan and zoom to the start location.

  4. Single-click on the map to start the trail.

This facility is provided within the free version. By default the track/trail may be public (inconsistent behaviour). It can optionally be marked as private under the 'Privacy' option on the Step 3/4 details screen.

-- Frank Dean - 26 Jan 2024

Avenza Maps

Avenza Maps provide apps for Android and iOS that work with geo-referenced TIFF maps. Paths and placemarks are imported using KML files.

See AvenzaMapsTips for more information.

GDAL

When installing gdal on macOS using Macports, install with the poppler variant to support converting geospatial PDF files to tiff.

$ sudo port install gdal +popler

See also:

Converting Latitude and Longitue to Image Pixels

QGIS

It appears that OpenLayers:900913 (Google transliterated to numbers) has been deprecated and you can use EPSG:3857 instead.

See http://wiki.openstreetmap.org/wiki/QGIS for details on using Open Street Map data with QGIS.

Importing GPS Data

Enable the GPS Tools plugin.

Note that not all data is imported, in particular relations are missing. See the following:

OpenStreetMap Styling Rules

The following rules to seem to work well for hiking trail types in the United Kingdom:

Rights of Way

  • Byway open to all traffic (BOAT) "designation" = 'byway_open_to_all_traffic'
  • Restricted byway "designation" = 'restricted_byway' OR ("highway" = 'byway' AND "designation" IS NULL)
  • Bridleway "highway" = 'bridleway'
  • Public footpath "highway" IN ( 'footway') OR ("foot" = 'yes' AND "designation" = 'public_footpath')

Other

  • Track "highway" = 'track' AND ("designation" NOT IN ('byway_open_to_all_traffic', 'restricted_byway') OR "designation" IS NULL)
  • Path "highway" IN ('path' , 'pedestrian') AND ("foot" = 'yes' OR "designation" NOT IN ('byway_open_to_all_traffic', 'restricted_byway') OR "designation" IS NULL)
  • Barrier "barrier" IN ('fence' , 'hedge', 'wall', 'wire_fence')
  • Railway "railway" = 'rail'
  • Stream "waterway" = 'stream'

Other features can usually be implemented as a simple attributes of the highway key. E.g. primary/primary_link/trunk/secondary/tertiary/unclassified/service/road/cycle_way/residential

Saving Geo-referenced Tiffs

Select Project -> Save as Image... from the menu. QGIS saves the image as a tif, together with a file of the same name, but with a 'tifw' extension. The 'tifw' file does not include the project, so it is necessary to include the project when using gdal_translate to create a proper geo-referenced tiff. E.g.

$ gdal_translate -a_srs EPSG:4326 example.tif example_ref.tif

Creating Garmin Custom Maps

Activate the GarminCustomMap plugin.

When you execute the plugin from the menu `Plugins->CustomGarminMap', the export dialog contains tabs which provide more information, e.g. estimation of the maximum number of tiles that will be produced at the current zoom level and what maximum zoom level you can use to stay within the limits of the target device.

Version 1.1 of this plugin didn't work well for me with Version 2.8 of QGIS, not rendering tiles properley when setting the zoom level greater than 1.0. Also, the Garmin eTrex 30 ignored KML files with the tag, expecting . I was able to fix the latter issue by modifying the Python code after installing the plugin. A restart of QGIS seems necessary to reload the plugin. The image rendering issue looks like some serious debugging will be required. QLandkarte GT produces sufficiently acceptable Custom Maps, although exporting the data from QGIS to QLandkarte GT is not straight-forward. However, there may be a solution based on using QGIS Server to serve tiles to QLandkarte GT. A job for another day.

See also http://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin

Developing Plugins

http://docs.qgis.org/2.8/en/docs/pyqgis_developer_cookbook/plugins.html

There are some notes on Debugging QGIS Plugins, but this looks like it's only relevant to those written in C++.

QGIS References

QGIS Server

Proj4

For Debian 7.0 (Wheezy) install the proj-bin package.

Using Proj4 to convert co-ordinates from lat/long WGS84 to OSGB

$ cs2cs +proj=latlong +ellps=WGS84 +towgs84=0,0,0 +nodefs +to \
  +proj=tmerc +ellps=airy +datum=OSGB36 \
  +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 \
  +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 \
  +units=m +no_defs << EOF
  6d12'7.38"W 57d23'25.38"N # NG 47600 41135
  -6d12'7.38" 57d23'25.38"
  -6.20205 57.390383
  6.20205W 57.390383N
  EOF

Note that the input values are longitude followed by latitude (x, y ordered).

and the inverse by adding the -I parameter:

$ cs2cs -I +proj=latlong +ellps=WGS84 +towgs84=0,0,0 +nodefs +to \
  +proj=tmerc +ellps=airy +datum=OSGB36 \
  +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 \
  +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 \
  +units=m +no_defs << EOF
  147600 841135
  147599.75 841134.99
  EOF

add a parameter of -f '%.8f' to output as decimal degrees:

$ cs2cs -I +proj=latlong +ellps=WGS84 +towgs84=0,0,0 +nodefs +to \
  +proj=tmerc +ellps=airy +datum=OSGB36 \
  +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 \
  +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 \
  +units=m +no_defs -f '%.8f' << EOF
  147600 841135
  147599.75 841134.99
  EOF

The values for +lat_0, _lon_0, +k, x_0, +y_0 are as published in Appendix A.2 of http://www.ordnancesurvey.co.uk/docs/support/guide-coordinate-systems-great-britain.pdf

See also:

WMTS

Web Map Tile Service - OGC Standard

Open Geospatial Consortium

gvSig

Open-source - Linux/Windows desktop application - Also have Android client

Converting TIFF World files to GeoTiff

In Debian, install the geotiff-bin package

geotifcp -e foo.tfw foo.tif geo_foo.tif

See http://maps.cga.harvard.edu/qgis/wkshop/export_GeoTiff.php

JOSM

JOSM is a Java based GUI for editing OpenStreetMap data.

Vespucci

Vespucci is Vespucci is and Android app for editing OpenStreetMap data.

OpenStreetMap

Elevation Data

Open Locations Codes (Plus Codes)

Miscellaneous

  • sextant Turbo Pascal Navigation 1991
  • Nanomaps - a small JavaScript library for displaying no-frills slippy maps on click and touch devices
  • nanomaps-server - a simple tile map server written in Java
  • iOS GPX Framework - a iOS framework for parsing/generating GPX files
  • Remember - Progressive web app using geolocation and device orientation in React with Redux
  • GoMap - Issue tracker for Go Map!!

References

Resources

-- Frank Dean - 4 Feb 2016

Related Topics:

AvenzaMapsTips, Garmin_eTrex30, GPSBabel, OsmAndMaps, ViewRangerTips