gplately icon indicating copy to clipboard operation
gplately copied to clipboard

geopandas.overlay throws NotImplementedError

Open michaelchin opened this issue 1 year ago • 6 comments

It happened when I tried to plot COBs of Muller2016. The COBs contains polygon, multipolygon and linestring.

Traceback (most recent call last): File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/./test_plot.py", line 107, in main(show=True) File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/./test_plot.py", line 83, in main getattr(gplot, f"plot_{key}")( File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/../../gplately/decorators.py", line 42, in wrapper return func_pointer(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/../../gplately/plot.py", line 818, in plot_continent_ocean_boundaries return self.plot_feature( ^^^^^^^^^^^^^^^^^^ File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/../../gplately/decorators.py", line 42, in wrapper return func_pointer(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/../../gplately/plot.py", line 698, in plot_feature return self._plot_feature(ax, partial(self.get_feature, feature), **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/../../gplately/plot.py", line 724, in _plot_feature gdf = _clean_polygons(data=gdf, projection=ax.projection) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mchin/workspace/gplately.git/tests-dir/unittest/../../gplately/utils/plot_utils.py", line 392, in _clean_polygons data = data.overlay(rects, how="difference") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mchin/micromamba/envs/gplately/lib/python3.11/site-packages/geopandas/geodataframe.py", line 2469, in overlay return geopandas.overlay( ^^^^^^^^^^^^^^^^^^ File "/Users/mchin/micromamba/envs/gplately/lib/python3.11/site-packages/geopandas/tools/overlay.py", line 274, in overlay raise NotImplementedError( NotImplementedError: df1 contains mixed geometry types.

michaelchin avatar Jul 03 '24 10:07 michaelchin

Yes, I’ve encountered this error too. I think that it is a mistake to bundle different geometry types in with the plate model. My preference is that these COBs are modified and uploaded to Zenodo or alternatively convert all these polygons / multi polygons to line strings to enforce a uniform geometry type. We can discuss at the next GPlates meeting.

brmather avatar Jul 08 '24 11:07 brmather

Yes, I’ve encountered this error too. I think that it is a mistake to bundle different geometry types in with the plate model. My preference is that these COBs are modified and uploaded to Zenodo or alternatively convert all these polygons / multi polygons to line strings to enforce a uniform geometry type. We can discuss at the next GPlates meeting.

Thanks Ben

michaelchin avatar Jul 09 '24 01:07 michaelchin

The client seemed not unhappy about modifying their dataset to avoid this error. See the email with a subject "Muller2016 COB Terranes".

michaelchin avatar Jul 10 '24 03:07 michaelchin

related to #226

michaelchin avatar Jul 18 '24 01:07 michaelchin

Have we a solution to this? If I remember correctly, the consensus was to convert any polylines to polygons...?

brmather avatar Sep 13 '24 05:09 brmather

@bsim8882 this Issue is related to https://github.com/GPlates/gplately/issues/226. The problem should go away once the https://github.com/GPlates/gplately/issues/226 is done.

michaelchin avatar Nov 27 '24 00:11 michaelchin