bellockk / alphashape

Toolbox for constructing alpha shapes.
MIT License
252 stars 28 forks source link

TypeError: 'MultiPoint' object is not iterable #45

Open larsschwarz opened 1 year ago

larsschwarz commented 1 year ago

Running alphashape 1.3.1 with Shapely 2.x returns TypeError: 'MultiPoint' object is not iterable error. This could be fixed by using the .geoms attribute in optimizealpha.py, however it returns a ZeroDivisionError: float division by zero in alphashape.py

Does anyone have a fix for running it with Shapely 2?

i404788 commented 12 months ago

Using pip3 install -U "shapely<2" with an example the following errors pop up:

lib/python3.11/site-packages/shapely/ops.py:42: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  source = iter(source)
lib/python3.11/site-packages/alphashape/optimizealpha.py:41: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  return all([polygon.intersects(point) for point in points])
lib/python3.11/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([

So it seems like maybe iterating over geoms or coords is needed depending on the type.

drs378 commented 12 months ago

I'm having the same issue with this too. The problem is exactly what is stated, which is that in the new version of Shapely, the MultiPoint object is no longer iterable which breaks a lot of alphashape functionality. This post confirms it

This is mostly for the developers on this side to handle. It involves re-writing both alphashape and optimizealpha

mjacobse commented 9 months ago

This looks like a duplicate of #37. As noted there, it has already been fixed on the master branch in #36. Unfortunately it just has not made it into a release yet. So for now you may want to install the version from the master branch with pip install git+https://github.com/bellockk/alphashape.git instead.