In most areas of the world, the magnetic compass is the ultimate heading reference. Although pilots look to the directional gyro most of the time when flying (because the directional gyro's reading is unaffected by the aircraft's pitch and bank attitude, unlike the magnetic compass), the directional gyro has to be periodically reset by reference to the magnetic compass,1 as the gyro's reading drifts over time due to a combination of
- friction in the gyro mechanism, and
- the fact that, as the earth is not an infinite stationary flat plane,
- an aircraft travelling in a straight line over the earth's surface will see a slow change in heading as its position relative to the earth's poles changes, while the directional gyro, which uses the aircraft's frame of reference, thinks that heading remains constant in straight flight, and
- the reading from a directional gyro on the earth's surface will cycle slowly throughout the course of the day as the earth rotates underneath it,2 while, because the earth's magnetic field rotates with the earth, a magnetic compass will experience no such precession.
Magnetic declination (the angle between true north and magnetic north, which is useful to know because maps are generally referenced to true north and because the direction of magnetic north shifts over time due to changes in the earth's magnetic field) changes as you fly from place to place. Part of this change is due to a combination of the earth (and its magnetic field) not being an infinite flat plane and of flow irregularities in the earth's liquid outer core (the source of the earth's magnetic field3); these changes are gradual and only matter much over long distances. However, some areas have large local irregularities in magnetic declination, due to large deposits of magnetic material in the ground (mostly the aptly-named magnetite, but some other iron-bearing minerals are also naturally magnetic and play a part in this). These large ore bodies, acting as giant magnets, cause magnetic declination to rapidly spike or swing as one passes over or through the area. For reasons that are hopefully obvious, these types of areas are marked on aeronautical charts used in air navigation.
Huge quantities of magnetic material are also found in large cities, primarily in the form of refined iron and steel alloys, alongside many possible sources of magnetization potentially orders of magnitude stronger than that from the earth's magnetic field (such as the magnetic fields produced by energized electrical-power-transmission lines or by lightning strikes on tall buildings, the use of powerful electromagnets in construction and heavy industry, and the ubiquitous use of weaker electromagnets and permanent magnets in electrical motors and generators, including the huge generators that energize the power grid). Additionally, while most areas with large local magnetic-declination variations are small enough to be flown through fairly quickly (minimizing the error picked up by the directional gyro while passing through the aforementioned area, and, thus, allowing one to simply "fly the gyro" and ignore the magnetic-compass indications until out of the magnetically-deviant area), the airspace in and near large cities has the potential to keep aircraft in the local airspace for prolonged periods (approaches, traffic circuits, holding patterns) and also tends to require more accurate and precise navigation to keep aircraft from colliding with each other or with the ground or ground-mounted obstacles, both of which would make relying on the drifting directional gyro4 increasingly risky and increase a pilot's reliance on their magnetic compass.
Is the iron and steel content of large modern cities great enough to significantly affect an aircraft's magnetic compass?
1: The exception to this is in areas near the earth's magnetic poles, where the earth's magnetic field points mostly straight up and down (making magnetic compasses unreliable), aircraft navigation uses true heading rather than magnetic, and the directional gyro itself serves as the heading reference and is set by other means (GPS or IRS if so equipped, otherwise by reference to ground landmarks or celestial navigation).
2: The effect of the earth's rotation on a spinning gyroscope can itself be useful; this is the basis of the marine gyrocompass, which exploits this to create an instrument that can reliably point to true north for as long as the earth continues to rotate. However, this alignment to true north is fairly slow and depends on the gyroscope's position in space continuing to move in, or very close to, the same direction as the earth's surface, and aircraft change position relative to the earth's surface too rapidly for a gyrocompass to be useful. Additionally, most gyrocompasses are weighted to keep the gyrocompass horizontal and allow the gyroscope to precess properly; the use of weights for this purpose requires that the direction of apparent down relative to the earth's surface remain essentially constant, which is almost always true on the large marine vessels generally equipped with gyrocompasses, and is never true on an aircraft except in perfectly-straight-and-level-and-unaccelerated flight.
3: Although a significant fraction of the earth's magnetic field is contributed by magnetic materials in the earth's crust, this is itself a result of these materials having been bathed in the magnetic field of the earth's core.
4: While an aircraft flying within a small area for an extended period of time will not experience the gradual change in direction-versus-heading produced by flying long distances over the earth's curved, finite surface, it will still accumulate directional-gyro error due to friction within the gyro and to the earth rotating under the aircraft and its gyro.