
For several years I've used the Pointless Waymarks CMS to keep a private journal of my outdoor activities. I care about my the data from my time outside and it gives me a private, durable, place to keep GPX data and phone snapshots.
It occurred to me recently that the Pointless Waymarks Project software wasn't taking advantage of an interesting piece of metadata from these photos: Image Direction.

The Pointless Waymarks Project code uses Drew Noakes' metadata-extractor-dotne and extracting the raw Image Direction information is easy enough - but the data is often stored as a Magnetic bearing...
Declination
Putting aside complicated mapping and GIS concerns one core challenge for even simple software is that true bearings are more easily applied in simpler mapping scenarios and simpler to understand on most paper hiking maps. So, to me, it makes more sense to store and show the true bearing for a photograph even if the metadata is a magnetic bearing.
The difference between true north and magnetic north is declination. Declination is an adjustment that you can apply to convert between magnetic and true bearings.
But because Magnetic North is slowly, constantly, changing and varies across the surface of the earth there is not a simple way to calculate declination. As you descend into the rabbit hole of translating between true and magnetic bearings you will like come across two different models:
- International Geomagnetic Reference Field (IGRF) | National Centers for Environmental Information (NCEI)
- World Magnetic Model (WMM) | National Centers for Environmental Information (NCEI)
These models are well outside of my field of expertise so I leave any detailed critique of the models and determination of what to use to the reader. What I did find that helped me decide on a model was this information from the National Centers for Environmental Information's Geomagnetism Frequently Asked Questions:
What is the difference between IGRF and WMM models?
The World Magnetic Model (WMM) and the International Geomagnetic Reference Field (IGRF) are estimated from the most recent data and are of comparable quality. The differences between IGRF and WMM are within expected model inaccuracy. The WMM is a predictive-only model and is valid for the current epoch (2020.0 to 2025.0). The IGRF is retrospectively updated and the latest update, IGRF-12 is valid for the years 1900.0 - 2020.0. While IGRF is produced by the voluntary research of the scientific community under the banner of the International Association of Geomagnetism and Aeronomy (IAGA), the WMM is produced by NCEI and the British Geological Survey (BGS) for the US and UK defense agencies with guaranteed quality, user support, and updates. For the U.S. Department of Defense, the U.K. Ministry of Defence, the North Atlantic Treaty Organization (NATO), the International Hydrographic Organization (IHO) and the Federal Aviation Administration (FAA) the standard is WMM. For other users, the choice between WMM and IGRF is arbitrary.
The IGRF model's historic coverage seems like a valuable feature for the Pointless Waymarks Project code so I decided to translate pyIGRF: Python 3.7 code for generating spot values from the International Geomagnetic Reference Field Model into C#. My decision was partly about learning, fun and a love of coding - not a business decision about ROI - and if you are reading this it is worth reviewing the available C# code/packages that I found and the API links below:
- Tronald/CoordinateSharp: CoordinateSharp is a simple .NET library written in C# that is designed to assist with geographic coordinate conversions, parsing, formatting, magnetic data, and location based celestial calculations such as sunset, sunrise, moonset, moonrise and more. There is a CoordinateSharp.Magnetic extension that includes calculations based on the WMM model.
- sibartlett/Geo: A geographic data library including, geographic types, support for GPS Data/GPX files, geographic calculations and geomagnetism calculations.
- noelex/GeographicLib.NET - GeographicLib is a small set of C++ classes for performing conversions between geographic, UTM, UPS, MGRS, geocentric, and local cartesian coordinates,for gravity (e.g., EGM2008), geoid height and geomagnetic field (e.g., WMM2020) calculations, and for solving geodesic problems. This is a native .NET implementation of GeographicLib written in pure C#
- etfovac/wmm-cs - Noted as having an outdated model but an interesting WinForms WMM Calculator - based on the code below.
- Magnetic Declination in C# – Blue Toque Consulting - code and brief information by Michael Coyle about declination calculations for TrueNorth Geospatial | Mapping software for backcountry enthusiasts and professionals (a .NET desktop app that appears to no longer be available). Code: oplopanax.ca/Downloads/MagVar.cs
- vkorotenko/NGeoMag: NGeoMag library - a C# port of Java code found here: Geomagnetic Utility Programs | National Centers for Environmental Information (NCEI)
There is an IGRF API available from the British Geological Survey:
- The IGRF Model (14th Generation) - the sample link on this page is useful.
- Geomagnetic Model Web Service: General Help for the API
- Geomagnetic Model Web Service: Parameters for the API
I based my C# code on pyIGRF because it was linked on this page: IAGA V-MOD Geomagnetic Field Modeling: International Geomagnetic Reference Field IGRF-13 (Note: do NOT use the version of the code linked on that page - it has an important bug that is fixed in linked GitHub repo). I did the first conversion of the Python code with GitHub Copilot, cleaned up and corrected the ai version, did another round of corrections by debugging thru both versions and then wrote a few tests based on data from IGRF Calculator. In the process I learned about a number of other IGRF Python projects - see Alternatives and Too many "IGRF"s.
Results:
- C# code for the IGRF Model with parameters for versions 13 and 14 included in the code: PointlessWaymarksTools/PointlessWaymarks.SpatialTools/IgrfMagneticModelTools.cs
- C# code for the BGS Geomagnetism API: PointlessWaymarksTools/PointlessWaymarks.SpatialTools/IgrfGeomagneticApi.cs
- Pointless Waymarks CMS:
- In the True North Photo Direction is now stored in the Metadata for Photos with conversions from Magnetic North done automatically
- The Content Map can now show Photo Direction lines
- The Photo Editor has a link to PeakFinder (great for identifying peaks and prominent features in a view) that uses photo direction
- If Locations are shown in generated Web Pages the Photo Direction is shown on the Photo Page
- Pointless Waymarks CMS and Pointless Waymarks GeoTools:
- New File Metadata Window that includes a map and Photo Direction (if relevant) with links to OpenStreetMap, Google Maps and PeakFinder.
PS - In the process of working on this code and looking carefully at some of my photos it didn't take long to find some photos where I could tell that the recorded Photo Direction was not accurate - it was a good reminder that all casually, incidentally, obtained location data will have inaccuracies!