Skip to content

Commit

Permalink
fix(gridgen): only add suffix for generated shpfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Nov 29, 2023
1 parent c63bfca commit 1d4282e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions flopy/utils/gridgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def add_refinement_features(self, features, featuretype, level, layers):
"""
Parameters
----------
features : str, list, or collection object
features : str or list, or collection object
features can be
a string containing the name of a shapefile
a list of points, lines, or polygons
Expand Down Expand Up @@ -435,15 +435,17 @@ def add_refinement_features(self, features, featuretype, level, layers):

# Create shapefile or set shapefile to feature
rfname = f"rf{len(self._rfdict)}"
if isinstance(features, list):
if isinstance(features, (str, os.PathLike)):
shapefile = features
elif isinstance(features, (list, tuple, np.ndarray)):
rfname_w_path = os.path.join(self.model_ws, rfname)
features_to_shapefile(features, featuretype, rfname_w_path)
shapefile = rfname
shapefile = f"{rfname}.shp"
else:
shapefile = features
raise ValueError(f"Features must be path-like or array-like")

self._rfdict[rfname] = [shapefile, featuretype, level]
sn = os.path.join(self.model_ws, f"{shapefile}.shp")
sn = os.path.join(self.model_ws, shapefile)
assert os.path.isfile(sn), f"Shapefile does not exist: {sn}"

for k in layers:
Expand Down

0 comments on commit 1d4282e

Please sign in to comment.