I am trying to get an overlay (intersection) of two geodataframes of polygons, but it returns me a ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
It's weird as far as I did an intersection some lines before without issue.
clip = gpd.overlay(result_join, concave_hull, how='intersection')
# ^^This one works well
clip.crs = {'init': 'epsg:3857'}
parc = gpd.read_file(parcellaire)
parc = gpd.GeoDataFrame(parc).drop(['name'], axis=1)
parc = parc.set_geometry('geometry')
parc = parc.explode()
parc = parc.buffer(0)
parc.crs = {'init': 'epsg:4326'}
parc = parc.to_crs({'init': 'epsg:3857'})
parc = gpd.GeoDataFrame(parc).rename(columns={0:'geometry'}).set_geometry('geometry')
zonage = gpd.overlay(clip, parc, how='intersection') # This one crashes
Full traceback :
File "/Tim/Google Drive/Fruition Sciences/Dev/Geomatic/Scripts/Zonage/Zonage_standalone.py", line 278, in <module>
zonage(shape)
File "/Tim/Google Drive/Fruition Sciences/Dev/Geomatic/Scripts/Zonage/Zonage_standalone.py", line 225, in zonage
zonage = gpd.overlay(clip, parc, how='intersection') # Intersection du zonage par le parcellaire
File "/usr/local/lib/python2.7/dist-packages/geopandas/tools/overlay.py", line 175, in overlay
prop2.drop(df2._geometry_column_name)])
File "/usr/local/lib/python2.7/dist-packages/pandas/core/reshape/concat.py", line 213, in concat
return op.get_result()
File "/usr/local/lib/python2.7/dist-packages/pandas/core/reshape/concat.py", line 372, in get_result
name = com._consensus_name_attr(self.objs)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/common.py", line 130, in _consensus_name_attr
if obj.name != name:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
To reproduce it ---> files
Command: python .../Zonage_standalone.py .../shpdetest 10 .../block.shp
explode
call, which results in a MultiIndex, and thengeopandas.overlay
fails on that due to the pandas bug.