Skip to content

Commit

Permalink
fix(GridIntersect): combine list of geometries using unary_union (#1923)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews authored and wpbonelli committed Aug 25, 2023
1 parent 4e00489 commit 22205f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions flopy/utils/gridintersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
if Version(shapely.__version__) < Version("1.8"):
warnings.warn("GridIntersect requires shapely>=1.8.")
shapely = None
if SHAPELY_GE_20:
from shapely import unary_union
else:
from shapely.ops import unary_union
else:
SHAPELY_GE_20 = False

Expand Down Expand Up @@ -1487,10 +1491,7 @@ def _intersect_linestring_structured(
tempverts.append(vertices[i])
ishp = ixshapes[i]
if isinstance(ishp, list):
if len(ishp) > 1:
ishp = shapely_geo.MultiLineString(ishp)
else:
ishp = ishp[0]
ishp = unary_union(ishp)
tempshapes.append(ishp)
nodelist = tempnodes
lengths = templengths
Expand Down

0 comments on commit 22205f4

Please sign in to comment.