I suspect you mean magnetic deviation (difference between true and magnetic North)
declination is the angle the local magnetic field makes with the horizontal
is the angle between magnetic north and true north. Magnetic deviation
is the error introduced in a compass by local magnetic fields (eg... by nearby iron or electromagnets). I was, as I originally stated, interested in declination.
If the GPS can be oriented in line with the vehicle's axis and a magnetometer/compass (is there a vehicle?) then heading bearings can be used to calibrate the declination. Assuming the compass has compensation for nearby iron masses...
The unit will be used on a vehicle although only when the vehicle is stationary. I suppose that the unit could detect when the vehicle is moving quickly in a straight line (using the GPS) then attempt to calibrate the compass. I hadn't really considered that. Quite a neat idea.
I have thought a bit more about this and I am starting to get cold feet. The project I am interested in is a vehicle mounted solar tracker that will be used in Europe and northern Africa to keep our leisure batteries topped up. Looking at the magnetic declination currently I see that from Agadir (western Morocco) to Istanbul (eastern Europe) and from Oslo (northern Europe) down to Nairobi (central Africa) the magnetic declination only varies from -8 deg to +4 deg. If we didn't correct for it at all our panel would be 8 degrees out in its positioning which would still provide very nearly cos(8 deg) = 0.990... of the energy falling on it.
On the other hand... it would be cool to just have an Arduino compatible magnetic declination library (especially something like a port of the NOAA library). In North America you have it a lot worse with declinations ranging from -14 deg to +18 deg, cos(18 deg) = 0.951... still not terrible actually but it would visually look like it was facing the wrong direction at nearly 20 degrees out!
Thanks so much for all these ideas and it does certainly look like creating such a library would be possible. I'm just not sure if I REALLY need it