ec-jrc / pyPoseidon

Framework for Hydrodynamic simulations
https://pyposeidon.readthedocs.io/
European Union Public License 1.2
20 stars 8 forks source link

dem module: coastline adjust raises error #109

Closed TPCollings closed 2 years ago

TPCollings commented 2 years ago

Hi there,

I've installed pyposeidon 0.6.0 using conda on ubuntu 20.04.

I'm trying to run the tutorial scripts and keep seeing a repeated error, related to shapely and geopandas. Example error is below.

This error is also thrown when doing adjust coastline command.

Having read up on this other people seem to think it is a bug caused by shapely 1.7.2, and they way it interacts with numpy, and that updating to shapely 1.8.0 solves the issue. I have tried to update and downgrade shapely but there are package dependencies that won't let it.

What would you suggest I do?

Thanks,

Tom

ne_i = gp.GeoDataFrame(geometry = [x for x in coast.geometries()])


NotImplementedError Traceback (most recent call last) Input In [100], in <cell line: 2>() 1 import geopandas as gp ----> 2 ne_i = gp.GeoDataFrame(geometry = [x for x in coast.geometries()])

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/geopandas/geodataframe.py:189, in GeoDataFrame.init(self, data, geometry, crs, *args, **kwargs) 181 if ( 182 hasattr(geometry, "crs") 183 and geometry.crs 184 and crs 185 and not geometry.crs == crs 186 ): 187 raise ValueError(crs_mismatch_error) --> 189 self.set_geometry(geometry, inplace=True, crs=crs) 191 if geometry is None and crs: 192 raise ValueError( 193 "Assigning CRS to a GeoDataFrame without a geometry column is not " 194 "supported. Supply geometry using the 'geometry=' keyword argument, " 195 "or by providing a DataFrame with column name 'geometry'", 196 )

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/geopandas/geodataframe.py:347, in GeoDataFrame.set_geometry(self, col, drop, inplace, crs) 344 level.crs = crs 346 # Check that we are using a listlike of geometries --> 347 level = _ensure_geometry(level, crs=crs) 348 frame[geo_column_name] = level 349 frame._geometry_column_name = geo_column_name

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/geopandas/geodataframe.py:62, in _ensure_geometry(data, crs) 60 return GeoSeries(out, index=data.index, name=data.name) 61 else: ---> 62 out = from_shapely(data, crs=crs) 63 return out

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/geopandas/array.py:150, in from_shapely(data, crs) 134 def from_shapely(data, crs=None): 135 """ 136 Convert a list or array of shapely objects to a GeometryArray. 137 (...) 148 149 """ --> 150 return GeometryArray(vectorized.from_shapely(data), crs=crs)

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/geopandas/_vectorized.py:110, in from_shapely(data) 108 arr = np.empty(len(data), dtype=object) 109 with compat.ignore_shapely2_warnings(): --> 110 arr[:] = data 111 else: 112 arr = data

File ~/anaconda3/envs/pypos_main1/lib/python3.8/site-packages/shapely/geometry/polygon.py:300, in Polygon.array_interface(self) 298 @property 299 def array_interface(self): --> 300 raise NotImplementedError( 301 "A polygon does not itself provide the array interface. Its rings do.")

NotImplementedError: A polygon does not itself provide the array interface. Its rings do.

brey commented 2 years ago

@TPCollings I was able to reproduce the problem. During the release there was a big transition of various upstream dependencies and the configuration in not stable. Things will be better later on.

For now, you can resolve the issues by downgrading NumPy. Just

conda install numpy==1.22.3 

works on my end.

TPCollings commented 2 years ago

Cheers @brey, this has solved my issue.

Thanks