Is it possible to "override" the Earth magnetic field locally? For a mobile application I am developing I would like to know which direction the phone is facing. In the outdoor we can of course use the magneto meter in combination with a gyroscope. 
However, indoors the magnetometer is too jumpy to use. 
This made me wonder whether it would be possible to place a electormagnet in a hall which would completely "override" the earth magnetic, so that magneto meter in the phone would yield steady values. 
The hall would measure about 50 x 50 meter.
 A: As long as you know the magnitude and direction of the Earth's field at that spot, it's very possible! Suppose you measure the magnitude of the field as $B_{earth}$ in tesla (T), and you set up a solenoid with $n$ turns per m. Then the current $I$ you need to run in the solenoid is as follows:
$$I = \frac{B_{earth}}{\mu_0 n}$$
where $\mu_0$ is the permeability of free space. Then the field generated by the solenoid will cancel the field from the Earth. Note that there will still be a non-zero field gradient, so the cancellation will only be perfect in one location, but the gradient of the Earth's field is typically small, so this shouldn't affect things much.
However,
The Earth's field doesn't vary too much over small regions of space. Therefore, a jumpy magnetometer would not be the result of Earth's field, but rather because either:


*

*Your magnetometer isn't sensitive enough or is somehow defective, or

*There are sources of magnetic interference indoors.
The first one is unlikely, since the problem only appears to happen indoors. The second is usually the case, since anything that has a current running through it generates a magnetic field. As long as the sources of interference are static (i.e. there's just a constant DC current running through the source), the solenoid setup should still work. But if the sources have AC current or time-varying DC current running through them, the solenoid won't be of much use. In that case, placing the magnetometer inside a Faraday cage (essentially a conducting cage connected to ground) will isolate it from any sources of interference.
