diff --git a/StreamCat.py b/StreamCat.py index 6fd0cc6..80e4469 100644 --- a/StreamCat.py +++ b/StreamCat.py @@ -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): @@ -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!!!" - ) \ No newline at end of file + ) diff --git a/StreamCat_functions.py b/StreamCat_functions.py index 773ad08..c714c40 100644 --- a/StreamCat_functions.py +++ b/StreamCat_functions.py @@ -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 @@ -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, )