@@ -1143,7 +1143,7 @@ def match_coordinates(
11431143 Distance to use for non-exact matching. Possible values are "euclidean", "haversine" and
11441144 "approx". Default: "euclidean"
11451145 unit : str, optional
1146- Unit to use for non-exact matching. Possible values are "degree", "m ", "km ".
1146+ Unit to use for non-exact matching. Possible values are "degree", "metre ", "kilometre ".
11471147 Default: "degree"
11481148 threshold : float, optional
11491149 If the distance to the nearest neighbor exceeds `threshold`, the index `-1` is assigned.
@@ -1238,13 +1238,15 @@ def match_coordinates(
12381238
12391239 coords = np .radians (coords )
12401240 coords_to_assign = np .radians (coords_to_assign )
1241- elif unit == "m " :
1241+ elif unit == "metre " :
12421242 coords *= 1e-3
12431243 coords_to_assign *= 1e-3
1244- elif unit == "km " :
1244+ elif unit == "kilometre " :
12451245 pass
12461246 else :
1247- raise ValueError ("Unit must be one of 'degree', 'm' or 'km'." )
1247+ raise ValueError (
1248+ "Unit must be one of 'degree', 'metre' or 'kilometre'."
1249+ )
12481250
12491251 not_assigned_idx_mask = assigned_idx == - 1
12501252 assigned_idx [not_assigned_idx_mask ] = nearest_neighbor_funcs [distance ](
@@ -1261,7 +1263,6 @@ def match_centroids(
12611263 coord_gdf ,
12621264 centroids ,
12631265 distance = "euclidean" ,
1264- unit = None ,
12651266 threshold = NEAREST_NEIGHBOR_THRESHOLD ,
12661267):
12671268 """Assign to each gdf coordinate point its closest centroids's coordinate.
@@ -1278,9 +1279,6 @@ def match_centroids(
12781279 Distance to use in case of vector centroids.
12791280 Possible values are "euclidean", "haversine" and "approx".
12801281 Default: "euclidean"
1281- unit : str, optional
1282- Unit to use for non-exact matching. Possible values are "degree", "m", "km".
1283- Default: None
12841282 threshold : float, optional
12851283 If the distance (in km) to the nearest neighbor exceeds `threshold`,
12861284 the index `-1` is assigned.
@@ -1319,9 +1317,8 @@ def match_centroids(
13191317 # no error is raised and it is assumed that the user set the crs correctly
13201318 pass
13211319
1322- # infer unit
1323- if not unit :
1324- unit = infer_unit_coords (coord_gdf )
1320+ # get unit of coordinate systems from axis of crs
1321+ unit = get_crs_unit (coord_gdf )
13251322
13261323 assigned = match_coordinates (
13271324 np .stack ([coord_gdf .geometry .y .values , coord_gdf .geometry .x .values ], axis = 1 ),
0 commit comments