diff --git a/Trajectories/cost_function.py b/Trajectories/cost_function.py
index bb15b146b665384f78a07bf137e8a02da1440b9b..5e4c82b1ad6522f3c120791f55e108ec020b983f 100755
--- a/Trajectories/cost_function.py
+++ b/Trajectories/cost_function.py
@@ -27,6 +27,7 @@ import graph_tool
 import util_eddies
 
 Omega = 2 * math.pi / 86164.0
+r_Earth = 6371  # radius of the Earth, in km
 
 
 def calculate_radii_rossby(properties):
@@ -240,10 +241,9 @@ for edge in g.edges():
     if lon_diff > math.radians(300):
         lon_diff = 2 * math.pi - lon_diff
 
-    Delta_Cent = math.sqrt(
-        (lon_diff * 6378.166175 * math.cos(latitude)) ** 2
-        + ((pos_last[source_node][1] - pos_first[target_node][1]) * 6335.423523)
-        ** 2
+    Delta_Cent = r_Earth * math.sqrt(
+        (lon_diff * math.cos(latitude)) ** 2
+        + (pos_last[source_node][1] - pos_first[target_node][1]) ** 2
     )
 
     # Rossbies: