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

Cannot plot model with edge geometries longer than a single line segment #1218

Closed
visr opened this issue Mar 6, 2024 · 1 comment · Fixed by #1223
Closed

Cannot plot model with edge geometries longer than a single line segment #1218

visr opened this issue Mar 6, 2024 · 1 comment · Fixed by #1223
Labels
python Relates to one of the Ribasim python packages

Comments

@visr
Copy link
Member

visr commented Mar 6, 2024

We support LineString and MultiLineString geometries for edges. But cannot plot model with edge geometries longer than a single line segment in Ribasim Python.

image

There are some similar limitations regarding edge geometries described in #352.

@github-project-automation github-project-automation bot moved this to To do in Ribasim Mar 6, 2024
@visr visr added python Relates to one of the Ribasim python packages bug labels Mar 6, 2024
@Huite
Copy link
Contributor

Huite commented Mar 6, 2024

In this case, we require return_index=True in the shapely.get_coordinates call I think.

https://shapely.readthedocs.io/en/stable/reference/shapely.get_coordinates.html

Then some indexing trickery to setup a matplotlib LineCollection.

@visr visr closed this as completed in #1223 Mar 8, 2024
visr pushed a commit that referenced this issue Mar 8, 2024
Fixes #1218

test_edge_plot:

![image](https://github.com/Deltares/Ribasim/assets/13662783/a6d270c5-407e-4234-9e27-001499273500)

And one of the testmodels I edited in QGIS to add additional vertices:

![image](https://github.com/Deltares/Ribasim/assets/13662783/58ff9234-6aa9-46b1-b9d6-b1c9b058ef77)

I also took the opportunity to use `.pop()` on the kwargs dicts.

The marker colors also had to be adjusted since there's no longer a 1:1
marked:edge_geometry relationship. I'm using a numpy array instead of
generating the list, since the arrays support indexing.
Using boolean indexing for setting the colors doesn't work very well
because the lengths of the color names might differ, and need to be
supplied as the dtype. `np.where` is clever enough to take care of it,
generating the right dtype on the fly.
@github-project-automation github-project-automation bot moved this from To do to ✅ Done in Ribasim Mar 8, 2024
Hofer-Julian pushed a commit that referenced this issue Mar 11, 2024
Fixes #1218

test_edge_plot:

![image](https://github.com/Deltares/Ribasim/assets/13662783/a6d270c5-407e-4234-9e27-001499273500)

And one of the testmodels I edited in QGIS to add additional vertices:

![image](https://github.com/Deltares/Ribasim/assets/13662783/58ff9234-6aa9-46b1-b9d6-b1c9b058ef77)

I also took the opportunity to use `.pop()` on the kwargs dicts.

The marker colors also had to be adjusted since there's no longer a 1:1
marked:edge_geometry relationship. I'm using a numpy array instead of
generating the list, since the arrays support indexing.
Using boolean indexing for setting the colors doesn't work very well
because the lengths of the color names might differ, and need to be
supplied as the dtype. `np.where` is clever enough to take care of it,
generating the right dtype on the fly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Relates to one of the Ribasim python packages
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants