You may be confusing a compass (which points to the earth's magnetic poles) with an altimeter, which measures altitude. They are two different instruments.

A compass, because it depends on the earth's magnetic field, is not affected by anything unless there is a large power source or large mass of metal nearby.

An altimeter actually measures air pressure, which of course varies with altitude. The altimeter needs to be adjusted to actual altitude (as found on a topographic map) frequently because the weather, as well as the altitude, affects air pressure. The standard saying is, if your altimeter shows that your campsite has lost considerable elevation overnight, a storm is on the way.

The problems with air pressure for an altimeter are why most people now rely on a GPS for altitude measurement. I understand that the GPS isn't 100% accurate, either.
_________________________
May your trails be crooked, winding, lonesome, dangerous, leading to the most amazing view--E. Abbey