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

Fix path interpretation for landscape layers. #141

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions StreamCat.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
mask_dir = ""
layer = (
row.LandscapeLayer
if os.sep in row.LandscapeLayer
if "/" in row.LandscapeLayer or "\\" in row.LandscapeLayer
else (f"{LYR_DIR}/{row.LandscapeLayer}")
) # use abspath
if isinstance(row.summaryfield, str):
Expand Down Expand Up @@ -191,4 +191,4 @@
"Be sure to delete the associated files in your `OUTDIR` to rerun:"
f"\n\t> {OUT_DIR}\n\n!!! `$OUT_DIR/DBF_stash/*` "
f"output used in 'Continuous' and 'Categorical' metrics!!!"
)
)
7 changes: 5 additions & 2 deletions StreamCat_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import sys
import time
from collections import OrderedDict, defaultdict, deque
from pathlib import Path
from typing import Generator

import numpy as np
Expand Down Expand Up @@ -965,16 +966,18 @@ def createCatStats(
arcpy.env.snapRaster = inZoneData
if by_RPU == 0:
if LandscapeLayer.count(".tif") or LandscapeLayer.count(".img"):
landscape_layer = Path(LandscapeLayer).stem # / vs. \ agnostic
outTable = "%s/DBF_stash/zonalstats_%s%s%s.dbf" % (
out_dir,
LandscapeLayer.split("/")[-1].split(".")[0],
landscape_layer,
appendMetric,
zone,
)
else:
landscape_layer = Path(LandscapeLayer).name # / vs. \ agnostic
outTable = "%s/DBF_stash/zonalstats_%s%s%s.dbf" % (
out_dir,
LandscapeLayer.split("/")[-1],
landscape_layer,
appendMetric,
zone,
)
Expand Down