Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: *** TypeError: 'MultiLineString' object is not iterable #1922

Closed
oscarfasanchez opened this issue Aug 18, 2023 · 1 comment · Fixed by #1923
Closed

bug: *** TypeError: 'MultiLineString' object is not iterable #1922

oscarfasanchez opened this issue Aug 18, 2023 · 1 comment · Fixed by #1923
Labels

Comments

@oscarfasanchez
Copy link
Contributor

oscarfasanchez commented Aug 18, 2023

Describe the bug
I'm using the flopy tools to intersect a shapefile with a structured grid in modflow 6, but when I run the ix.intersect command I get the following error:

resultq=ix.intersect(shp_geomq)

*** TypeError: 'MultiLineString' object is not iterable
in the files:
File c:\users\oscar\documents\git_repos\thesis_mf6_pest\09_python\modelo.py:547 in setup_drn_creeks
resultq=ix.intersect(shp_geomq)

File ~\anaconda3\envs\THESIS_MASTER\Lib\site-packages\flopy\utils\gridintersect.py:277 in intersect
rec = self._intersect_linestring_structured(

File ~\anaconda3\envs\THESIS_MASTER\Lib\site-packages\flopy\utils\gridintersect.py:1491 in _intersect_linestring_structured
ishp = shapely_geo.MultiLineString(ishp)

File ~\anaconda3\envs\THESIS_MASTER\Lib\site-packages\shapely\geometry\multilinestring.py:50 in new
line = linestring.LineString(lines[i])

File ~\anaconda3\envs\THESIS_MASTER\Lib\site-packages\shapely\geometry\linestring.py:66 in new
coordinates = [_coords(o) for o in coordinates]

To Reproduce
here I attach my dis package and the shapefile
the snippet is something like the following

import  shapefile as sf 
from shapely.geometry import shape, MultiLineString

ix = GridIntersect(gwf.modelgrid, method="structured", rtree=False)
...
...
queb=sf.Reader(os.path.join(path_sh,"Queb_corr.shp"))

list_shp = []
for i in range(1,queb.numRecords):
        queb1=queb.shapeRecords()[i]
        firstq=queb1.shape.__geo_interface__
        # shp_geomq=shp_geomq.union(shape(firstq))
        list_shp.append(shape(firstq))
shp_geomq=MultiLineString(lines=list_shp)
resultq=ix.intersect(shp_geomq)

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: WIndows 11
  • running on spyder
  • Flopy Version '3.4.1'

Additional context
attachment
bug.zip

thanks in advance for any help

@mwtoews
Copy link
Contributor

mwtoews commented Aug 21, 2023

See #1923 for potential fix

dbrakenhoff added a commit to dbrakenhoff/flopy that referenced this issue Aug 21, 2023
mwtoews pushed a commit that referenced this issue Aug 21, 2023
wpbonelli pushed a commit that referenced this issue Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants