An interpolation method to evaluate magnetic fields, given its unstructured and scattered magnetic data, is presented. The method is based on the reconstruction of the global magnetic field using a superposition of orthogonal functions. The coefficients of the expansion are obtained by minimizing a cost function defined as the L2 norm of the difference between the ground truth and the reconstructed magnetic field evaluated on the training data. The divergence-free condition is incorporated as a constraint in the cost function, allowing the method to achieve arbitrarily small errors in the magnetic field divergence. An exponential decay of the approximation error is observed and compared with the less favorable algebraic decay of local splines. Compared to local methods involving computationally expensive search algorithms, the proposed method exhibits a significant reduction of the computational complexity of the field evaluation, while maintaining a small error in the divergence even in the presence of magnetic islands and stochasticity. Applications to the computation of Poincaré sections using data obtained from numerical solutions of the magnetohydrodynamic equations in toroidal geometry are presented and compared with local methods currently in use.