Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

418 add mask raster CLI function #419

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions eis_toolkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,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
Loading