calculating nearest grid point and distance