Skip to content

Commit

Permalink
Merge pull request #419 from GispoCoding/418-add-mask-raster-cli-func…
Browse files Browse the repository at this point in the history
…tion

418 add mask raster CLI function
  • Loading branch information
nmaarnio committed Aug 26, 2024
2 parents f58f69b + a2fa1b8 commit 1d69439
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 @@ -1588,6 +1588,30 @@ def surface_derivatives_cli(
typer.echo(f"Calculating first and/or second order surface attributes completed, writing raster to {output_raster}")


@app.command()
def mask_raster_cli(
input_raster: INPUT_FILE_OPTION,
base_raster: INPUT_FILE_OPTION,
output_raster: OUTPUT_FILE_OPTION,
):
"""Mask input raster using the nodata locations from base raster."""
from eis_toolkit.raster_processing.masking import mask_raster

typer.echo("Progress: 10%")

with rasterio.open(input_raster) as raster:
with rasterio.open(base_raster) as base_rstr:
typer.echo("Progress: 25%")
out_image, out_meta = mask_raster(raster=raster, base_raster=base_rstr)
typer.echo("Progress: 75%")

with rasterio.open(output_raster, "w", **out_meta) as dest:
dest.write(out_image)
typer.echo("Progress: 100%")

typer.echo(f"Raster masking completed, writing raster to {output_raster}")


@app.command()
def reclassify_with_manual_breaks_cli(
input_raster: INPUT_FILE_OPTION,
Expand Down

0 comments on commit 1d69439

Please sign in to comment.