How can I calculate magnetic field strength from any given latitude longitude?
The Earth's field is not something you calculate from scratch. Instead, go to the National Geodetic Data Center and use their calculator:
Now the gravity field is stored as spherical harmonic coefficients that can be downloaded along with Fortran code to compute the values, or the data can be downloaded as a grid and interpolated as needed.
A similar protocol is available for the International Geomagnetic Reference Field: