@@ -1174,13 +1174,15 @@ def match_coordinates(
11741174
11751175 check_if_geo_coords (coords [:, 0 ], coords [:, 1 ])
11761176 check_if_geo_coords (coords_to_assign [:, 0 ], coords_to_assign [:, 1 ])
1177- elif unit == "m" :
1178- coords *= 1e-3
1179- coords_to_assign *= 1e-3
1180- elif unit == "km" :
1181- pass
1182- else :
1183- raise ValueError ("Unit must be one of 'degree', 'm' or 'km'." )
1177+ elif unit != "km" :
1178+ LOGGER .warning (
1179+ "You are using coordinates systems defined in %s. "
1180+ "The following distance threshold will be used for coordinates "
1181+ "matching: %i %s. Please adapt the distance threshold if needed. " ,
1182+ unit ,
1183+ threshold ,
1184+ unit ,
1185+ )
11841186
11851187 not_assigned_idx_mask = assigned_idx == - 1
11861188 assigned_idx [not_assigned_idx_mask ] = nearest_neighbor_funcs [distance ](
@@ -1471,7 +1473,11 @@ def _nearest_neighbor_euclidean(
14711473 centroids = np .rad2deg (centroids )
14721474 coordinates = np .rad2deg (coordinates )
14731475 dist = dist * EARTH_RADIUS_KM
1476+ threshold_unit = "km"
14741477 else :
1478+ threshold_unit = (
1479+ unit # the unit of the threshold is considered to be in input unit
1480+ )
14751481 if check_antimeridian :
14761482 # if unit is not in degree, check_antimeridian is forced to False
14771483 check_antimeridian = False
@@ -1486,8 +1492,9 @@ def _nearest_neighbor_euclidean(
14861492 num_warn = np .sum (dist > threshold )
14871493 if num_warn :
14881494 LOGGER .warning (
1489- "Distance to closest centroid is greater than %i km for %i coordinates." ,
1495+ "Distance to closest centroid is greater than %i %s for %i coordinates." ,
14901496 threshold ,
1497+ threshold_unit ,
14911498 num_warn ,
14921499 )
14931500 assigned [dist > threshold ] = - 1
0 commit comments