SorooshMani-NOAA / OCSMeshTutorial

This repository stores files and documentation used for OCSMesh tutorial Sessions
Creative Commons Zero v1.0 Universal
2 stars 1 forks source link

Error with iterating over multi-part geometry #6

Closed melissamattwig closed 1 year ago

melissamattwig commented 1 year ago

Not sure if this was resolved yet somewhere else, but when going through the tutorial I ran into an issue while trying to adjust the mesh after making local modifications. There was a warning in the tutorial about iteration over multi-part geometries being deprecated with shapely 2.0. I got an error when running this chunk of code:

hfun_obj_3.add_patch(
    test_polygon_1,
    expansion_rate=0.001,
    target_size=300
)

that 'MultiPolygon' object is not iterable. Is there a way to adjust the code to fix this?

Thank you!

SorooshMani-NOAA commented 1 year ago

@melissamattwig good catch! I just realized I missed updating this part of OCSMesh when adding support for shapely version 2.0. I'll fix the code and release it to PyPI, then all you need to do to fix this is to call pip install --upgrade ocsmesh in your environment. I'll let you know when I add the fix.

SorooshMani-NOAA commented 1 year ago

@melissamattwig actually since you're already working on the tutorial, would it be possible to just install the version from the fix branch before I merge it? That way if there are other issues I can fix them as well. This tutorial was developed before shapely 2.0 was released, so I might have missed some other stuff as well!

To install from the branch, you can call

pip install git+https://github.com/noaa-ocs-modeling/ocsmesh.git@bugfix/shapely2

in case you don't have git, you can install it in your conda environment using conda install git I've already added some minor changes to that branch. It should take care of this specific issue, but please let me know if you noticed something like this again going through the tutorial. Thanks!

melissamattwig commented 1 year ago

Will do!! I'll let you know if I have any issues.

melissamattwig commented 1 year ago

The issue that I had with the multipolygon iterations was fixed, I do have another issue that's come up with the raster based geometry and size function. I'm getting this error:

RasterioIOError: Attempt to create new tiff file 'C:/Users/mattwig/AppData/Local/Temp/1/ocsmesh/ulvxvwxg' failed: Permission denied

Do you know what permission needs to change and whether that's something I can change on my work computer without speaking to someone in IT?

SorooshMani-NOAA commented 1 year ago

OK, thanks for testing. I remember there was this weird permission issue with temp directory on Windows, I'm not sure how to fix the permission, but to avoid the issue in your environment you can set TMPDIR to a location where you know you have write permission, before launching jupyter lab

So for example since you were using an Anaconda PowerShell, you can do:

$Env:TMPDIR = "C:\Users\mattwig\Desktop\mytempdir"

and then start Jupyter and see if it is resolved. Just make sure that the mytempdir directory in the example value above exists whatever you set it to.

SorooshMani-NOAA commented 1 year ago

@melissamattwig since the original issue related to shapely 2 support is resolved by the update, I'll close this ticket after merging the branch, but please let me know if you run into any other issues. Thanks!