Skip to content

Commit 999424d

Browse files
authored
319 add CLI function for local morans i (#320)
1 parent dc4927f commit 999424d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

eis_toolkit/cli.py

+33
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ class NodataHandling(str, Enum):
200200
remove = "remove"
201201

202202

203+
class LocalMoranWeightType(str, Enum):
204+
"""Weight type for Local Moran's I."""
205+
206+
queen = "queen"
207+
knn = "knn"
208+
209+
203210
RESAMPLING_MAPPING = {
204211
"nearest": warp.Resampling.nearest,
205212
"bilinear": warp.Resampling.bilinear,
@@ -497,6 +504,32 @@ def descriptive_statistics_vector_cli(input_file: Annotated[Path, INPUT_FILE_OPT
497504
typer.echo("Descriptive statistics (vector) completed")
498505

499506

507+
# LOCAL MORAN'S I
508+
@app.command()
509+
def local_morans_i_cli(
510+
input_vector: Annotated[Path, INPUT_FILE_OPTION],
511+
output_vector: Annotated[Path, OUTPUT_FILE_OPTION],
512+
column: str = typer.Option(),
513+
weight_type: LocalMoranWeightType = LocalMoranWeightType.queen,
514+
k: int = 4,
515+
permutations: int = 999,
516+
):
517+
"""Execute Local Moran's I calculation for the data."""
518+
from eis_toolkit.exploratory_analyses.local_morans_i import local_morans_i
519+
520+
typer.echo("Progress: 10%")
521+
522+
gdf = gpd.read_file(input_vector)
523+
typer.echo("Progress: 25%")
524+
525+
out_gdf = local_morans_i(gdf, column, weight_type, k, permutations)
526+
typer.echo("Progress: 75%")
527+
528+
out_gdf.to_file(output_vector)
529+
typer.echo("Progress: 100%")
530+
typer.echo(f"Local Moran's I completed, output vector saved to {output_vector}.")
531+
532+
500533
# --- RASTER PROCESSING ---
501534

502535

0 commit comments

Comments
 (0)