Question about target_length

3 views
Skip to first unread message

Yeonju Kim

unread,
Oct 9, 2025, 1:16:40 PM (14 hours ago) Oct 9
to Amanzi-ATS Users
Hi, I am Yeonju.

Since the ATS short course 2 months ago, I have been using the example code to apply to my watershed with target_length with a geodatabase file (my own file, not the default of hydrography source).

My geodatabase file (streamline)'s properties are 

--------------------------------------------------------------------------------------------------------------
UniqueID 153 stream_order 4 ShreveID 77 HackID 1 InLine_FID 153 target_length NaN Shape_Length 584.296496 geometry LINESTRING (2163829.098526541 287624.466491983... ID 152 name 152 Name: 0, dtype: object
-------------------------------------------------------------


I have tried naming of target_length as "target_segment_length" too, but it raises the same error

--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[35], line 4 1 watershed, rivers = createCopy(watershed_orig, rivers_orig) 3 # simplifying -- this sets the discrete length scale of both the watershed boundary and the rivers ----> 4 watershed_workflow.simplify(watershed, rivers, refine_L0, refine_L1, refine_d0, refine_d1, resample_by_reach_property=True) 6 # simplify may remove reaches from the rivers object 7 # -- this call removes any reaches from the dataframe as well, signaling we are all done removing reaches 8 # 9 # ETC: NOTE -- can this be moved into the simplify call? 10 for river in rivers: File /mnt/c/Users/pqh24002/watershed-workflow/watershed_workflow/__init__.py:358, in simplify(hucs, rivers, reach_segment_target_length, huc_segment_target_length, river_close_distance, river_far_distance, resample_by_reach_property, min_angle, junction_min_angle, snap_triple_junctions_tol, plot_diagnostics, keep_points) 356 if resample_by_reach_property: 357 logging.info(f" -- resampling reaches based on TARGET_SEGMENT_LENGTH property") --> 358 watershed_workflow.resampling.resampleRivers(rivers, keep_points=keep_points) 359 else: 360 logging.info(f" -- resampling reaches based on uniform target {reach_segment_target_length}") File /mnt/c/Users/pqh24002/watershed-workflow/watershed_workflow/resampling.py:137, in resampleRivers(rivers, target_length, keep_points) 133 def resampleRivers(rivers: List[River], 134 target_length: float | ComputeTargetLength | None = None, 135 *, keep_points: bool = False) -> None: 136 for river in rivers: --> 137 _resampleRiverArgs(river, target_length, keep_points) File /mnt/c/Users/pqh24002/watershed-workflow/watershed_workflow/resampling.py:169, in _resampleRiverArgs(river, target_length, keep_points) 165 def _resampleRiverArgs(river : River, 166 target_length : Optional[float | ComputeTargetLength] = None, 167 keep_points : bool = False) -> None: 168 if target_length is None: --> 169 _resampleRiver(river, ComputeTargetLengthByProperty(), keep_points) 170 elif isinstance(target_length, ComputeTargetLength): 171 _resampleRiver(river, target_length, keep_points) File /mnt/c/Users/pqh24002/watershed-workflow/watershed_workflow/resampling.py:184, in _resampleRiver(river, computeTargetLength, keep_points) 182 """Resamples a river, in place, given a strategy to compute the target segment length.""" 183 for node in river.preOrder(): --> 184 ls2 = resampleLineStringUniform(node.linestring, computeTargetLength(node), keep_points) 185 logging.debug(f' - resampling ls: {node.linestring.length}, {min(watershed_workflow.utils.computeSegmentLengths(node.linestring))}, {min(watershed_workflow.utils.computeSegmentLengths(ls2))}') 186 node.linestring = ls2 File /mnt/c/Users/pqh24002/watershed-workflow/watershed_workflow/resampling.py:62, in ComputeTargetLengthByProperty.__call__(self, reach) 61 def __call__(self, reach): ---> 62 return reach.properties[names.TARGET_SEGMENT_LENGTH] NameError: name 'names' is not defined -------------------------------------------------------------------------



Thanks,
Yeonju

Reply all
Reply to author
Forward
0 new messages