Skip to content

Commit

Permalink
pass explore args directly
Browse files Browse the repository at this point in the history
  • Loading branch information
knaaptime committed Oct 28, 2023
1 parent 1e31c6b commit d4a444d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions esda/moran.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ def get_cluster_labels(self, crit_value=0.05):
"""
return _get_cluster_labels(self, crit_value)

def explore(self, gdf, crit_value=0.05, explore_kwargs=None, m=None):
def explore(self, gdf, crit_value=0.05, **kwargs):
"""Create interactive map of LISA indicators
Parameters
Expand All @@ -1210,10 +1210,8 @@ def explore(self, gdf, crit_value=0.05, explore_kwargs=None, m=None):
geodataframe used to conduct the local Moran analysis
crit_value : float, optional
critical value to determine statistical significance, by default 0.05
explore_kwargs : dict, optional
additional keyword arguments passed to the geopandas `explore` method, by default None
m : Folium.Map, optional
instance of a folium map canvas to plot on, by default None
kwargs : dict, optional
additional keyword arguments passed to the geopandas `explore` method
Returns
-------
Expand All @@ -1223,7 +1221,7 @@ def explore(self, gdf, crit_value=0.05, explore_kwargs=None, m=None):
gdf = gdf.copy()
gdf["Moran Cluster"] = self.get_cluster_labels(crit_value)
return _explore_local_moran(
self, gdf, crit_value, explore_kwargs=explore_kwargs, m=m
self, gdf, crit_value, **kwargs
)


Expand Down Expand Up @@ -1749,7 +1747,7 @@ def by_col(
df[col] = rate_df[col]


def _explore_local_moran(moran_local, gdf, crit_value, explore_kwargs=None, m=None):
def _explore_local_moran(moran_local, gdf, crit_value, **kwargs):
"""Plot local Moran values as an interactive map
Parameters
Expand All @@ -1760,18 +1758,19 @@ def _explore_local_moran(moran_local, gdf, crit_value, explore_kwargs=None, m=No
geodataframe used to create the Moran_Local class
crit_value : float, optional
critical value for determining statistical significance, by default 0.05
explore_kwargs : dict, optional
additional keyword arguments passed to geopandas.explore, by default None
m : folium.Map, optional
folium map canvas to plot on top of, by default None
kwargs : dict, optional
additional keyword arguments are passed directly to geopandas.explore, by default None
Returns
-------
m
folium.Map
"""
if explore_kwargs is None:
explore_kwargs = dict()
if kwargs is None:
kwargs = dict()
if 'cmap' in kwargs:
del kwargs['cmap']

gdf = gdf.copy()
gdf["Moran Cluster"] = moran_local.get_cluster_labels(crit_value)
gdf["p-value"] = moran_local.p_sim
Expand All @@ -1787,11 +1786,9 @@ def _explore_local_moran(moran_local, gdf, crit_value, explore_kwargs=None, m=No
}
colors5 = [colors5_mpl[i] for i in y] # for mpl
hmap = colors.ListedColormap(colors5)
if "cmap" in explore_kwargs.keys():
del explore_kwargs["cmap"]

m = gdf[["Moran Cluster", "p-value", "geometry"]].explore(
"Moran Cluster", cmap=hmap, **explore_kwargs
"Moran Cluster", cmap=hmap, **kwargs
)
return m

Expand Down

0 comments on commit d4a444d

Please sign in to comment.