find_matched_layer_names¶
- pydriosm.utils.find_matched_layer_names(layer_names, available_layer_names, cutoff=0.4)[source]¶
Find corresponding OSM layer names by identifying common semantic roots.
This function attempts to match input strings to a list of available layer names by extracting the core “root” of the word (e.g., stripping Geofabrik prefixes and plural suffixes). If no direct root match is found, it falls back to fuzzy string matching.
- Parameters:
layer_names (str | list) – One or more layer names to search for.
available_layer_names (list | collections.abc.Iterable) – A list of valid layer names (e.g., from a GeoPackage).
cutoff (float) – Similarity threshold for the fuzzy match fallback; defaults to
0.4.
- Returns:
A list of unique matched layer names.
- Return type:
list
Examples:
>>> from pydriosm.utils import find_matched_layer_names >>> layers = ['gis_osm_water_a_free_1', 'gis_osm_roads_free_1', 'pois'] >>> find_matched_layer_names('water', layers) ['gis_osm_water_a_free_1'] >>> find_matched_layer_names(['road', 'water'], layers) ['gis_osm_roads_free_1', 'gis_osm_water_a_free_1']