Skip to content

Commit

Permalink
Update the add_nwi method (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs authored Oct 8, 2024
1 parent a689a83 commit 7de8374
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions leafmap/foliumap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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".
Expand All @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions leafmap/leafmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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".
Expand All @@ -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,
Expand Down

0 comments on commit 7de8374

Please sign in to comment.