Skip to content

Commit

Permalink
feat(CLI): use distance_to_anomaly_gdal in CLI for Windows users
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaarnio committed Oct 23, 2024
1 parent ccc9675 commit 384f829
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions eis_toolkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,9 @@ def distance_to_anomaly_cli(
Uses only the first band of the raster.
"""
from eis_toolkit.raster_processing.distance_to_anomaly import distance_to_anomaly
from sys import platform

from eis_toolkit.raster_processing.distance_to_anomaly import distance_to_anomaly, distance_to_anomaly_gdal

typer.echo("Progress: 10%")

Expand All @@ -1286,13 +1288,23 @@ def distance_to_anomaly_cli(

with rasterio.open(input_raster) as raster:
typer.echo("Progress: 25%")
out_image, out_meta = distance_to_anomaly(
anomaly_raster_profile=raster.profile,
anomaly_raster_data=raster.read(1),
threshold_criteria_value=threshold_criteria_value,
threshold_criteria=get_enum_values(threshold_criteria),
max_distance=max_distance,
)
# Use optimized version if Windows
if platform == "win32":
out_image, out_meta = distance_to_anomaly_gdal(
anomaly_raster_profile=raster.profile,
anomaly_raster_data=raster.read(1),
threshold_criteria_value=threshold_criteria_value,
threshold_criteria=get_enum_values(threshold_criteria),
max_distance=max_distance,
)
else:
out_image, out_meta = distance_to_anomaly(
anomaly_raster_profile=raster.profile,
anomaly_raster_data=raster.read(1),
threshold_criteria_value=threshold_criteria_value,
threshold_criteria=get_enum_values(threshold_criteria),
max_distance=max_distance,
)

typer.echo("Progress: 75%")

Expand Down

0 comments on commit 384f829

Please sign in to comment.