Skip to content

Commit

Permalink
buffer fix and multipart check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan committed Dec 2, 2022
1 parent 733300c commit 2409116
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# VBET 2 v2.1
Valley Bottom Extraction Tool (updated: 04/18/2022)
Valley Bottom Extraction Tool (updated: 12/02/2022)

VBET uses a stream network shapefile and digital elevation model to derive a valley bottom
polygon based on two lines of evidence: slope and inundation depth. The values for these
Expand Down
21 changes: 11 additions & 10 deletions classVBET.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, **kwargs):
self.med_depth = kwargs['med_depth']
self.sm_depth = kwargs['sm_depth']

self.version = '2.1.1'
self.version = '2.1.2'

if not os.path.isdir(os.path.dirname(self.out)):
os.mkdir(os.path.dirname(self.out))
Expand Down Expand Up @@ -123,15 +123,22 @@ def __init__(self, **kwargs):

# check that there are no segments with less than 5 vertices
few_verts = []
multipart = []
for i in self.network.index:
if len(self.network.loc[i].geometry.xy[0]) <= 5:
few_verts.append(i)
if self.network.loc[i].geometry.type == 'MultiLineString':
multipart.append(i)
if len(few_verts) > 0:
self.md.writelines('\n Exception: There are network segments with fewer than 5 vertices. Add vertices in '
'GIS \n')
self.md.close()
raise Exception("Network segments with IDs ", few_verts, "don't have enough vertices for DEM detrending. "
"Add vertices in GIS")
if len(multipart) > 0:
self.md.writelines('\n Exception: There are multipart features in the input stream network \n')
self.md.close()
raise Exception('There are multipart features in the input stream network')

# add container for individual valley bottom features and add the minimum buffer into it
self.polygons = []
Expand Down Expand Up @@ -444,18 +451,12 @@ def valley_bottom(self):
da = seg['Drain_Area']
seg_geom = seg.geometry

# print('segment ', i+1, ' of ', len(self.network.index))
pts = []
for pt in seg_geom.boundary.geoms:
pts.append([pt.xy[0][0], pt.xy[1][0]])
line = LineString(pts)

if da >= self.lg_da:
buf = line.buffer(self.lg_buf, cap_style=1)
buf = seg_geom.buffer(self.lg_buf, cap_style=1)
elif self.lg_da > da >= self.med_da:
buf = line.buffer(self.med_buf, cap_style=1)
buf = seg_geom.buffer(self.med_buf, cap_style=1)
else:
buf = line.buffer(self.sm_buf, cap_style=1)
buf = seg_geom.buffer(self.sm_buf, cap_style=1)

bufds = gpd.GeoSeries(buf)
coords = self.getFeatures(bufds)
Expand Down

0 comments on commit 2409116

Please sign in to comment.