diff --git a/leafmap/foliumap.py b/leafmap/foliumap.py index 000e5117f2..dde3da1751 100644 --- a/leafmap/foliumap.py +++ b/leafmap/foliumap.py @@ -3121,6 +3121,7 @@ def oam_search( def add_nwi( self, data: Union[str, "gpd.GeoDataFrame"], + col_name: str = "WETLAND_TY", add_legend: bool = True, style_callback: Optional[Callable[[dict], dict]] = None, layer_name: str = "Wetlands", @@ -3131,6 +3132,7 @@ def add_nwi( Args: data (Union[str, gpd.GeoDataFrame]): The NWI data to add. It can be a file path or a GeoDataFrame. + col_name (str): The column name to use for styling. Defaults to "WETLAND_TY". add_legend (bool): Whether to add a legend to the map. Defaults to True. style_callback (Optional[Callable[[dict], dict]]): A callback function to style the features. Defaults to None. layer_name (str): The name of the layer to add. Defaults to "Wetlands". @@ -3155,8 +3157,8 @@ def nwi_color(feature): return { "color": "black", "fillColor": ( - nwi[feature["properties"]["WETLAND_TY"]] - if feature["properties"]["WETLAND_TY"] in nwi + nwi[feature["properties"][col_name]] + if feature["properties"][col_name] in nwi else "gray" ), "fillOpacity": 0.6, diff --git a/leafmap/leafmap.py b/leafmap/leafmap.py index e8651c3d8e..1e3b0b05f7 100644 --- a/leafmap/leafmap.py +++ b/leafmap/leafmap.py @@ -5573,6 +5573,7 @@ def batch_edit_lines( def add_nwi( self, data: Union[str, "gpd.GeoDataFrame"], + col_name: str = "WETLAND_TY", add_legend: bool = True, style_callback: Optional[Callable[[dict], dict]] = None, layer_name: str = "Wetlands", @@ -5583,6 +5584,7 @@ def add_nwi( Args: data (Union[str, gpd.GeoDataFrame]): The NWI data to add. It can be a file path or a GeoDataFrame. + col_name (str): The column name in the GeoDataFrame that contains the wetland types. add_legend (bool): Whether to add a legend to the map. Defaults to True. style_callback (Optional[Callable[[dict], dict]]): A callback function to style the features. Defaults to None. layer_name (str): The name of the layer to add. Defaults to "Wetlands". @@ -5607,8 +5609,8 @@ def nwi_color(feature): return { "color": "black", "fillColor": ( - nwi[feature["properties"]["WETLAND_TY"]] - if feature["properties"]["WETLAND_TY"] in nwi + nwi[feature["properties"][col_name]] + if feature["properties"][col_name] in nwi else "gray" ), "fillOpacity": 0.6,