Good morning guys,
I would like to calculate the RMSE error between two gps coordinates (latitude and longitude).
Do you know if and how I can apply it to a known coordinate pair?
Good morning guys,
I would like to calculate the RMSE error between two gps coordinates (latitude and longitude).
Do you know if and how I can apply it to a known coordinate pair?
RMSE of latitude/longitude:
Using numpy you can do the following for longitude, and same for the latitude.
import numpy as np
longitude = [1,2,3,4,5]
longitude_pred = [1.6,2.5,2.9,3,4.1]
MSE_longitude = np.square(np.subtract(longitude, longitude_pred)).mean()
RMSE_longitude = np.sqrt(MSE)
If your coordinates is matrix of shape [2, n]:
import numpy as np
long_lat = [[1,2,3,4,5], [1,2,3,4,5]]
long_lat_pred = [[1.6,2.5,2.9,3,4.1], [1.6,2.5,2.9,3,4.1]]
MSE_long_lat = np.square(np.subtract(long_lat, long_lat_pred)).mean(axis=1)
RMSE_long_lat = np.sqrt(MSE)
Distance between coordinates in meters:
To get a value in meters, you can for example calculate the distance between each points ((long, lat), (long_pred, lat_pred)) in meter using the Haversine formula. (More info on Getting distance between two points based on latitude/longitude) But you can't get the RMSE in meters I think.
For one set of coordinates and predictions you can calculates the distance using geopy:
import geopy.distance
coords_1 = (52.2296756, 21.0122287)
coords_2 = (52.406374, 16.9251681)
print(geopy.distance.geodesic(coords_1, coords_2).km)
>>> 279.352901604
Then for a set of coordinates:
coords_1 = np.array([[52.2296756, 21.0122287], [53.2296756, 22.0122287]])
coords_2 = np.array([[52.406374, 16.9251681], [51.406374, 18.9251681]])
distance_in_meters = [geodesic(coord1, coord2).km for coord1, coord2 in zip(coords_1, coords_2)]
print(distance_in_meters)
>>> [279.35290160430094, 292.3121626267748]