Skip to content

Commit

Permalink
Add unique_combinations_cli function (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
msorvoja authored Jan 18, 2024
1 parent 4fed630 commit 1df8d23
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions eis_toolkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,30 @@ def unify_rasters_cli(
typer.echo(f"Unifying completed, writing rasters to {output_directory}.")


# GET UNIQUE COMBINATIONS
@app.command()
def unique_combinations_cli(
input_rasters: INPUT_FILES_ARGUMENT,
output_raster: Annotated[Path, OUTPUT_FILE_OPTION],
):
"""Get combinations of raster values between rasters."""
from eis_toolkit.raster_processing.unique_combinations import unique_combinations

typer.echo("Progress: 10%")
rasters = [rasterio.open(rstr) for rstr in input_rasters]

typer.echo("Progress: 25%")
out_image, out_meta = unique_combinations(rasters)
[rstr.close() for rstr in rasters]
typer.echo("Progress: 75%")

with rasterio.open(output_raster, "w", **out_meta) as dst:
dst.write(out_image, 1)

typer.echo(f"Writing results to {output_raster}.")
typer.echo("Getting unique combinations completed.")


# EXTRACT WINDOW
@app.command()
def extract_window_cli(
Expand Down

0 comments on commit 1df8d23

Please sign in to comment.