Wednesday, September 12, 2012

How to Determine Magnetic Declination Information for a Topographic Map

rev20120912a

This post is a companion to my How to Create and Print Custom Canadian Topographic Maps with Quantum GIS post.

The grid printed on a Canadian Topographic map is a UTM grid.  UTM Grid North (GN) is not the same as Magnetic North (MN), so to conveniently and accurately use the map with a compass; the grid declination (angle between MN and GN) must be documented on the map.  This value is constantly changing so the year it was determined and the estimated annual change should also be recorded on the map.  Annual declination change predictions are not accurate over more than a few years so if the declination information for a map was calculated using a magnetic model more than about 5 years old, it should be recalculated with a declination calculator that is using an up to date magnetic model, not just adjusted by the old annual change amount.  Declination varies by location, but for a large scale map (like 1:50,000) the convention is to document the declination for the centre of the map sheet as the change over the sheet is too small to be significant for compass work.

The UTM map grid doesn’t point to True North (TN) except in the centre of a UTM zone and can point +/- several degrees off of TN at the edge of a zone.  Declination calculators provide the declination from TN so the grid convergence angle (angle between GN and TN) for the location the declination was calculated for should also be determined to accurately determine the grid declination for that location.  The grid convergence angle should also be documented on the map in case a TN reference is required.

One way to determine the declination information is to look at a printed topo map or download a print ready topo map file and determine the information from it.  The disadvantages of this are that the map must be available, is should be reasonably current, and the information from it must be manually transcribed.  The declination on older maps, even corrected for annual change, will not be as accurate as it could be so really should be re-calculated.  The UTM grid convergence angle does not change over time so this value will always be current.  This information is provided in Degrees and decimal Minutes (DM.M) on Canadian topo maps.

A more accurate way to determine the declination information is to use one of the readily available free on-line declination calculators such as the US NOAA Estimated Value of Magnetic Declination calculator.  Enter the desired date and the Latitude and Longitude values from QGIS Coordinate Capture, removing the minus (-) from the Longitude value.  For Canada, Latitude will always be N (North) and Longitude will always be W (West).  The NOAA calculator displays the Declination and Annual Change.  The declination provided is the angle between MN and TN and should be corrected by subtracting the UTM grid convergence angle for the location.

Formulas for manual UTM grid convergence angle calculations are available on-line but are complex and not feasible for most people. Fortunately, the UTM grid convergence angle can readily be determined by using one of several free on-line coordinate conversion calculators that provide it, such as the US NGS Geodetic Tool Kit UTM Coordinate calculators. The NGS Latitude/Longitude to UTM calculator requires Latitude/Longitude in DMS format but QGIS directly provides D.D format, so it is easier to use the NGS UTM to Latitude/Longitude calculator rather than converting to DMS.  Enter the UTM zone and the UTM coordinates from QGIS (Easting, Northing); adding a decimal point at the end of the Northing and Easting values if they don’t already include one since this calculator requires a decimal point be present. For Canada, select Northern Hemisphere, NAD83 (in most cases) and WEST. The grid convergence angle is provided in DMS.S which will likely need to be converted to decimal degrees (D.D); an on-line Latitude/Longitude coordinate conversion calculator can be used to do this.

There are also several free GUI or command line computer applications that will calculate convergence and declination.  A good option for Windows or Linux users are the MagneticField and GeoConvert command line utilities supplied with GeographicLib. MagneticField requires that the GeographicLib wmm2010 magnetic field model also be installed.  If a number of maps are being produced, these utilities can be provided with a file containing multiple coordinates and process many in one execution, potentially saving quite a bit of work compared to manually processing each individually using GUI utilities.

I am not a mapping expert so please comment on this post to correct any errors or suggest better ways to do things.


Given a date and Lat/Long, MagneticField can calculate the magnetic declination angle and the annual change for that date and location.  Example:

> magneticfield -r -t 2012-06-01 --input-string "44.80023 -62.69268"   <--- Given Date, Lat and Long, calculate the Magnetic Declination angle and Annual Change
-18.25 67.51 19900.4 18899.6 -6231.4 48078.0 52033.8   <--- The first number is the magnetic declination angle in decimal degrees
0.14 -0.10 47.7 60.4 30.8 -118.6 -91.4   <--- The first number is the magnetic declination angle annual change in decimal degrees


Given UTM or Lat/Long coordinates, GeoConvert can calculate the UTM convergence angle for that location.  Example:

>geoconvert -c --input-string "44.80023 -62.69268"   <--- Given Lat and Long, calculate the UTM Grid Convergence angle
0.21655 0.9996073   <--- The first number is the grid convergence angle in decimal degrees


The Grid Declination angle that should be recorded on the map is the Magnetic Declination angle less the UTM Grid Convergence angle.  Example:

-18.25° - 0.22° = -18.47° (in 2012, plus 0.14° annually)   <--- This can also be stated as 18.47°W (2012) decreasing 0.14° annually or 18.47°W (2012), annual change 0.14°E, either of which are probably less confusing


Latitude and Longitude may be expressed in Degrees Minutes Seconds (DMS) or decimal Degrees (D.D) or Degrees and decimal Minutes (DM.M) and also N/S/E/W or +/- may be used for direction so some geographic coordinate conversion may be required while working with these values.  A number of online coordinate conversion calculators are available; the GeoConvert utility can also perform many of these conversions.


Click here for some links to useful mapping information and calculators.

How to Create and Print Custom Canadian Topographic Maps with QGIS

rev20120917a

This post describes how to create and print customized Canadian Topographic (topo) maps using free digital topographic map information made available on the Internet by the Government of Canada (NRCan) and the free Quantum GIS (QGIS) computer application. QGIS can also be used to create maps from other free or commercial digital map information such as Open Street Map or US nautical charts (Canadian digital nautical charts are available but not free) but that is not covered in here.

QGIS is free Geographic Information System (GIS) software that runs on Windows, MacOS and Linux. Because QGIS will seamlessly join map files and has a Print Composer that enables map scale, area displayed and rotation angle to be specified, custom maps can be created containing just the area of interest without regard for standard topo map sheet boundaries or orientation. This is very useful when a large format plotter isn’t available to print full size map sheets as just the area of interest can be printed on standard letter or legal paper sizes using a normal home or office printer. It also facilitates the production of coastal or trail strip maps showing just the immediate area around the coastline or trail for kayaking or hiking.

For maps files to be seamlessly joined, they must be georeferenced and have no collars (borders). Paper topo maps can be scanned and then edited to eliminate collars and georeferenced with some effort, but NRCan has made it easy by providing the freely downloadable Toporama 1:50,000 raster map series. The Toporama map files are indexed by the National Topographic System grid, are already georeferenced (GeoTIFF or GeoPDF), collarless, have no grid overlay, and are available in either UTM or Lat/Long projections. For kayaking and hiking purposes, the UTM projection would generally be the best choice as a 1 km UTM grid, which is very useful for navigation, can easily be overlaid on the map. The Toporama maps are based on the most recent NRCan CanVec vector topographic information database and a new edition is released twice a year so they are about as up to date as Canadian Gov't topo maps can be.

NRCan also provide a publicly available Toporama Web Map Service (WMS) on the Internet. QGIS can load any required Canadian Topographic map data from the Toporama WMS directly. The advantage is that topo maps for any area in Canada can be directly accessed via QGIS without needing to identify, download and store local GeoTIFF map files on the QGIS workstation. Also, the map layers are individually accessible in case that is of value. The disadvantage is that high speed Internet access is required while working in QGIS and accessing the WMS is slower than using local map files. The Toporama WMS can supply many projections but UTM would generally be the best choice for kayaking and hiking.

The WMS and downloadable map files appear to use different styles so there may be a preference for one or the other. At the current time, several of the Toporama WMS layers, including the Feature Names layer are not scaled correctly for larger scale maps (like 1:50,000) so their text or content is too large and obscures other map features. This is not the case with the downloadable Toporama map files which appear to have all features properly scaled for 1:50000.  It is possible to use both map files and the WMS at the same time as long as the file layer is in front of the WMS layer, this could be useful to fill in around the edges of a map file without going to the effort of downloading adjacent maps.

Assuming a PC and Internet connection are available, Canadian topo maps can be created with no cost other than some time and effort, unless paper maps are required. If paper maps are required, an available printer can be used with any associated paper and ink or toner costs; or PDF maps can be created and sent to a commercial printing service such as Staples Copy & Print Centre. Because topo maps are intended to be viewed in colour, map features on monochrome printouts can be difficult to distinguish so colour printing is very desirable.

This post was initially inspired by the instructions in section 8 of the UBC VOC Online mapping page.  I have been interested in producing my own coastal strip maps for sea kayaking for many years, but until I recently ran across the UBC VOC page, had not found a feasible and inexpensive way to do so.

I am not a mapping, GIS or QGIS expert so please comment on this post to correct any errors or suggest better ways to do things.


Install the current QGIS version (1.8.0 at the time this was written)
  • Download the current version for your OS from http://download.qgis.org/
  • Install QGIS.  For Windows, run the downloaded installer; for Mac, click here and follow the instructions; for Linux, follow the instructions on the download page.

Loading Toporama UTM 1:50000 GeoTIFF Maps into QGIS

Loading Maps from the Toporama WMS into QGIS
  • Map information is downloaded on the fly via the Internet, map files aren’t required
  • A description of the Toporama WMS and each of its layers can be found at: http://geogratis.cgdi.gc.ca/geogratis/en/service/toporama.html
  • Open Quantum GIS Desktop
  • Settings -> Project properties - CRS (set the default CRS for this project)
  • Select Enable 'on the fly' CRS transformation
  • Set the CRS. For most of Nova Scotia the CRS should be NAD83 / UTM zone 20N if printing Topo type maps
  • Layer -> Add WMS Layer, or click the toolbar button
  • (If Toporama WMS not defined) Layers tab -> New
  • (If Toporama WMS not defined) Set Name to Toporama,
    set URL to http://wms.ess-ws.nrcan.gc.ca/wms/toporama_en, click OK
  • Ensure the Toporama WMS is selected
  • Click Connect
  • Select 0 WMS-Toporama for all layers, or expand the second item +1 Toporama to select one or more specific layers. The WMS will respond much more quickly if all the required layers are selected at once as one QGIS layer rather than individually as separate QGIS layers. Separate layers allow rendering order to be controlled (determine which layers are on top).
  • Set Image encoding to PNG24, the layer will be larger and download more slowly than if JPEG were selected but should be better quality for printing
  • Click Add
  • If selecting multiple separate layers for QGIS, select the next layer or layers, ensure the CRS is correct (there seems to be a bug and QGIS may hang if this isn’t correct), click Add and repeat as required. In the current QGIS release (1.8.0), to keep the CRS when adding multiple separate layers, select the new layer(s) before unselecting the previous layer(s).
  • Click Close when finished adding Toporama WMS layers
  • (Optional) In the Layers panel, if multiple layers were added and they are to be re-ordered, drag the layers into the required rendering order
  • File -> Save Project As...
  • Give the project a name and select the project file location
  • File -> New Print Composer, or click the toolbar button

(Optional) Loading a GPS track (*.gpx) into QGIS
  • In the Layers panel on the right side of the QGIS screen, select one of the map layers added above
  • Layer -> Set Project CRS from Layer, set the project CRS the same as the selected map layer
  • Settings -> Project properties -> Coordinate Reference System (CRS)
  • Select Enable 'on the fly' CRS transformation
  • Under Recently used coordinate reference systems, verify that the highlighted CRS matches the loaded map layers. For most of Nova Scotia the CRS should be NAD83 / UTM zone 20N.
  • Vector -> GPS -> GPS Tools -> Load GPX file
  • Browse to the *.gpx file containing the required GPS track and open it
  • Set the required Feature types (Tracks at least)
  • A layer for the GPS track should now be present on the map
  • In the Layers panel on the right side of the QGIS screen, select the GPS track layer added above
  • Layer -> Properties... -> Style
  • Set the track colour, symbol, etc. as required
  • (Optional) In the Layers panel, clear the X from the selection box to the left of the GPS track layer to prevent it from displaying and printing

Creating the printable map in QGIS Print Composer
  • A QGIS Project can have multiple Print Composers defined. In most cases, a separate one would probably be defined for each map page to be printed. Also, a Print Composer can have more than one map defined so an inset overview map could be added to a sheet or a single sheet could have multiple small maps on it, etc.
  • In the QGIS Print Composer window (not the Quantum GIS window)
  • Composition -> Paper and quality (panel on the right side of the Print Composer screen)
  • Set the paper format (Legal, ANSI A or ANSI B) and orientation (Landscape or Portrait)
  • Note the Width and Height shown for the selected paper size
  • Select Print as Raster at 300 dpi (this seems to work better for printing the grid and makes the exported PDF smaller)
  • Layout -> Add Map, or click the Toolbar button
  • Use the mouse to draw a rectangle. This area will display the map currently loaded into QGIS
  • Item Properties -> Map (on the right side of the Print Composer screen)
  • Set the Width and Height to that of the paper (from above) less about 6 mm in each dimension because laser printers can't print to the edge of a page
  • Set the Scale to 1:50000 or whatever scale is required
  • Use the mouse to centre the map on the page (drag)
  • View -> Zoom Full, or click the Toolbar button
  • Layout -> Move Content, or click the Toolbar button
  • Use the mouse to Pan (drag) and Zoom (mouse wheel) the map to the area of interest
  • Layout -> Move Item, or click the Toolbar button (this is required for selection in addition to move)
  • Click on the map to select it
  • Item Properties -> Map, set the Rotation (in degrees) to maximize the coastline shown on the page. Start by estimating the required rotation and adjust as required.
  • Re-adjust the area of interest that is displayed as required
  • Item Properties -> General options (below the Map, Extents and Grid sections)
  • (Optional) Unselect Show Frame to eliminate the map frame

To add a 1 km UTM grid on the printed map
  • Layout -> Move Item, or click the Toolbar button (this is required for selection in addition to move)
  • Click on the map to select it
  • Item Properties -> Grid (below Map and Extents sections)
  • Enable Show Grid
  • Set Interval X and Interval Y to 1000 (for a 1km grid)
  • Set Line color to a medium gray (too light and it won't be legible, too dark and it will be distracting)
  • (Optional) Enable Draw annotation to print the UTM grid coordinates on the edge of the map
  • Set Annotation position to Inside frame or as required
  • Set Annotation direction to Boundary direction
  • Set Font… -> Size to 4 or whatever size is required
  • Set Coordinate precision to 0.

To add a Scalebar
  • Layout -> Add Scalebar, or click the Toolbar button
  • Click the map to add the scale bar
  • Click on the scale bar to select it
  • Item Properties -> General options (below the Scale bar section)
  • Slide the Opacity slider all the way to the left to make it transparent
  • Unselect Show Frame to eliminate the frame
  • Item Properties -> Scale bar
  • Set Segment size and Map units per bar to 1000 (for a 1 km scale)
  • Set the Style, Left and Right segments, Height, etc. so that the scalebar has the desired appearance
  • Set Unit label to km
  • Set Font… -> Size as required
  • Use the mouse to drag the scalebar to the desired location on the map and size it as required

To add map scale text (e.g. 1:50000)
  • Layout -> Add Scalebar, or click the Toolbar button
  • Click the map to add the scale bar
  • Click on the scale bar to select it
  • Item Properties -> General options (below the Scale bar section)
  • Slide the Opacity slider all the way to the left to make it transparent
  • Unselect Show Frame to eliminate the frame
  • Item Properties -> Scale bar
  • Set the Style to Numeric
  • Set Font… -> Size as required
  • Use the mouse to drag the scale text to the desired location on the map and size it as required

To add a North Arrow
  • Layout -> Add Image, or click the Toolbar button
  • Click the map to add an image placeholder
  • Click on the image placeholder to select it
  • Item Properties -> General options
  • Slide the Opacity slider all the way to the left to make it transparent
  • Unselect Show Frame to eliminate the frame
  • Item Properties -> Picture options
  • Select the North Arrow image you like from the images shown
  • Select Sync with map to cause the North Arrow to align with the map regardless of map rotation
  • Use the mouse to drag the North Arrow to the desired location on the map and size it as required

To add a Map Title or other text
  • Layout -> Add Label, or click the Toolbar button
  • Click the map to add a Label placeholder
  • Click on the Label placeholder to select it
  • Item Properties -> General options
  • Slide the Opacity slider all the way to the left to make it transparent
  • Unselect Show Frame to eliminate the frame
  • Item Properties -> Label
  • Enter the required text
  • Set the Font… -> Size, Font colour… and Alignment as required
  • Use the mouse to drag the Label to the desired location on the map and size it as required

To add Magnetic Declination information on the map
  • In the main Quantum GIS window (not the QGIS Print Composer)
  • (If not already present) View -> Panels -> select Coordinate Capture to display the Coordinate Capture panel on the right side of the QGIS screen
  • (If the Coordinate Capture Panel is not listed) Plugins -> Manage Plugins… -> enable the Coordinate Capture plugin, then perform the previous step again
  • View -> Pan map, or click the Toolbar button
  • Use the mouse to pan the map so the center of the area to be printed is showing
  • In the Coordinate Capture panel
  • Click Start capture
  • Click on the centre of the area to be printed, the Coordinate Capture panel should now display the Longitude, Latitude and Easting, Northing (UTM) coordinates for the centre of the map. The more common coordinate order is Latitude, Longitude and Northing so depending on what they are being used for, the coordinate order may need to be swapped.
  • To determine the UTM zone, Settings -> Project properties -> Coordinate Reference System (CRS) -> Recently used coordinate reference systems, the project CRS will be highlighted in this section and, for a UTM CRS, should list the UTM zone.
  • Use the captured coordinates, UTM zone and date to determine the grid declination (angle between magnetic north and grid north) and its annual change (see my How to Determine Magnetic Declination Information for a Topographic Map post for details).
  • Use text and/or arrows to document the grid declination, the year for which it was determined and the annual change. Documenting the grid convergence angle is probably also a good idea.

When map composition is completed
  • Layout -> Move Item, or click the Toolbar button
  • Click on the map to select it (not on the Scale, Arrow, Title, etc.)
  • Item Properties -> Map
  • verify that the scale is still 1:50000 or whatever was set (sometimes it can be changed during map composition)
  • File -> Export as PDF, or click the Toolbar button
  • (If additional maps sheets will be required) File -> Save as template, saves the paper size, grid, scale, north arrow, text, etc. to be used when new print composers are created
  • Provide a meaningful name for the print composer template
  • In the main Quantum GIS window (not the QGIS Print Composer)
  • File -> Composer Manager..., or click the Toolbar button
  • Select the Print Composer that has just been completed and rename it to something meaningful
  • File -> Save Project, or click the Toolbar button

To compose additional maps in the same QGIS project
  • The above steps can be repeated as required to add multiple print composers to a QGIS project, a separate print composer should be defined for each separate map sheet required
  • To make this easier, a print composer template should be saved from the first print composer completed or from another project
  • In the main Quantum GIS window (not the QGIS Print Composer)
  • File -> New Print Composer, or click the toolbar button
  • In the QGIS Print Composer window (not the Quantum GIS window)
  • File ->Load from template
  • Select a saved Print Composer template
  • View -> Zoom Full, or click the Toolbar button
  • Click on Map will be printed here text to select the map (not on the Scale, Arrow, Title, etc.)
  • Item Properties -> Map
  • In the dropdown list box, change Rectangle to Cache
  • If required, click Update preview
  • Layout -> Move Content, or click the Toolbar button
  • Use the mouse to Pan (drag) and Zoom (mouse wheel) the map to the area of interest
  • Layout -> Move Item, or click the Toolbar button (this is required for selection in addition to move)
  • Click on the map to select it
  • Item Properties -> Map, set the Rotation (in degrees) to maximize the coastline shown on the page. Start by estimating the required rotation and adjust as required.
  • Re-adjust the area of interest that is displayed as required
  • Move, resize or update the Scale, Arrow, North arrow, Title, Declination information, etc. as required (see the steps above)
  • When completed, follow the When map composition is completed step above

Print the maps
  • Open the QGIS generated PDFs and print them. Ensure that automatic scaling, shrinking or fit to page are not enabled, if they are, the map scale will not be correct.
  • If the PDF page size is larger than the available printer paper size, the Adobe Reader print function using the Poster options (click the Poster button in the Adobe Reader print dialogue) can split it up onto multiple sheets of paper which can be taped or glued together if a single large sheet is required.

To reprint or edit the same maps later
  • Open Quantum GIS Desktop
  • File -> Open recent projects -> project name, to reopen the saved project
  • File -> Print Composers -> composer name, to reopen a saved print composer
  • Follow whichever steps from above are required

Click here for some links to useful mapping information and calculators.

Some Links to Useful Mapping, GIS and QGIS Information and Calculators

rev20120912a

Mapping, GIS and QGIS information

Tutorial: Making Maps for Print Using QGIS
http://qgis.spatialthoughts.com/2012/06/making-maps-for-print-using-qgis.html

Some QGIS Map Composer videos on YouTube
http://www.youtube.com/results?search_query=qgis+map+composer

Tutorial: Using Online Data via WMS in Quantum GIS
http://qgis.spatialthoughts.com/2012/05/tutorial-using-online-data-via-wms-in.html

Some articles about magnetic declination for maps
http://geomag.nrcan.gc.ca/mag_fld/magdec-eng.php
http://www.rescuedynamics.ca/articles/MagDecFAQ.htm#DETERMINE
http://geokov.com/education/magnetic-declination-inclination.aspx
http://en.wikipedia.org/wiki/Magnetic_declination

Some articles about UTM projections
http://www.nrcan.gc.ca/earth-sciences/geography-boundary/mapping/topographic-mapping/10733
http://geokov.com/education/utm.aspx
http://www.uwgb.edu/dutchs/FieldMethods/UTMSystem.htm
http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

Magnetic Declination, UTM and Datum - Cartographic information for SAR practitioners
http://www.tcgsar.nb.ca/index.php/document-library/doc_download/105-op3-mag-dec-utm-and-datum.html


A Map of Canadian UTM zones
http://www.geod.rncan.gc.ca/images/utm.jpg

A “.kml” of Canadian UTM zones (save target as a .kml file, then open in Google Earth)
http://www.geod.nrcan.gc.ca/tools-outils/kml/utm.kml

You can also view it on Google Maps
https://maps.google.ca/maps?q=http://www.geod.nrcan.gc.ca/tools-outils/kml/utm.kml


Toporama Specifications, Legend and Release Notes:
http://geogratis.cgdi.gc.ca/geogratis/en/collection/6E21C619-5823-363E-5985-355EED78D635.html
http://ftp2.cits.rncan.gc.ca/pub/toporama/doc/

Toporama WMS information
http://geogratis.cgdi.gc.ca/geogratis/en/service/toporama.html

An NTS index ".kmz" file is available on the CanMatrix FTP site.
When opened in Google Earth, the file shows the entire NTS grid overlaid on Canada and can zoom down to the individual 1:50000 map sheet level.
http://ftp2.cits.rncan.gc.ca/pub/index/nts_snrc.kmz



Calculators

Online Latitude / Longitude Coordinate converters (DMS <-> DM.M <-> D.D)
http://www.earthpoint.us/Convert.aspx (also calculates UTM convergence angle; to 0.1° only)
http://www.csgnetwork.com/gpscoordconv.html
http://en.wikipedia.org/wiki/Geographic_coordinate_conversion

Online magnetic declination calculators
http://www.ngdc.noaa.gov/geomag-web/#declination
http://geomag.nrcan.gc.ca/calc/mdcal-eng.php

Online calculators to convert UTM to Lat/Long and vice versa
http://www.ngs.noaa.gov/TOOLS/utm.shtml (also calculates UTM convergence angle)
http://www.geod.rncan.gc.ca/tools-outils/tools_info_e.php?apps=gsrug
http://www.uwgb.edu/dutchs/usefuldata/ConvertUTMNoOZ.HTM


Geographic Magnetic Calculator (Windows GUI utility), this will to convert UTM <-> Lat/Long, determine the UTM convergence angle and calculate magnetic declination but doesn’t provide the annual change
http://www.resurgentsoftware.com/geomag.html

GeographicLib (Windows, Unix, Linux) includes GeoConvert and MagneticField command line utilities to convert UTM <-> Lat/Long, determine the UTM convergence angle and calculate magnetic declination
http://geographiclib.sourceforge.net/

The magnetic field models required for the GeographicLib MagneticField utility (install the wmm2010 model at least)
http://geographiclib.sourceforge.net/html/magnetic.html#magneticinst