How to use the libpysal.weights.distance.Kernel function in libpysal

To help you get started, we’ve selected a few libpysal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spatialucr / geosnap / geosnap / analyze / dynamics.py View on Github external
"""

    gdf_temp = gdf.copy().reset_index()
    df = gdf_temp[[id_var, time_var, cluster_col]]
    df_wide = (
        df.pivot(index=id_var, columns=time_var, values=cluster_col)
        .dropna()
        .astype("int")
    )
    y = df_wide.values
    if w_type is None:
        mar = Markov(y)  # class markov modeling
    else:
        gdf_one = gdf_temp.drop_duplicates([id_var])
        gdf_wide = df_wide.merge(gdf_one, left_index=True, right_on=id_var)
        w_dict = {"rook": Rook, "queen": Queen, "knn": KNN, "kernel": Kernel}
        w = w_dict[w_type].from_dataframe(gdf_wide)
        w.transform = "r"
        mar = Spatial_Markov(
            y, w, permutations=permutations, discrete=True, variable_name=cluster_col
        )
    return mar