본문 바로가기

Error note

[Python]ValueError: Cannot render objects with any missing geometries

folium으로 choropleth을 이용해 지도 시각화를 할 때,

ValueError: Cannot render objects with any missing geometries와 같은 오류가 발생했다.

 

이경우 데이터의 type을 확인해보자.

<class 'pandas.core.frame.DataFrame'>가 아닌  <class 'geopandas.geodataframe.GeoDataFrame'>으로 데이터를 넣어야 한다. 

 

해결) geodataframe과 dataframe의 데이터를 merge할 때, geodataframe에 dataframe을 merge해야 한다. 

pd.merge()로 merge할 경우 위 같은 에러발생

# 해결 예시
df #DataFrame
geodf #GeoDataFrame

# geodf로 merge해야함
geodf = geodf.merge(df, left_on="col_1", right_on="col_2", how="outer")

 

 

참고 사이트 :

 

ValueError: Cannot render objects with any missing geometries when using a geopandas dataframe

I am trying to add a choropleth layer on a folium map using a geopandas dataframe that I built by merging a shapefile containing all the regions in Brazil (named "map_1"), with a regular pandas dat...

stackoverflow.com

 

반응형