From 23ffaecd56a329726c7b9ad3af3c9d27ccd16b46 Mon Sep 17 00:00:00 2001 From: Matthias Kraus Date: Fri, 26 May 2023 16:03:35 +0200 Subject: [PATCH] [jupyter] Fix error when adding a geodataframe with multiple geometry columns Co-authored-by: Felix Lattemann Co-authored-by: Andreas Hackeloeer Signed-off-by: Matthias Kraus --- bindings/kepler.gl-jupyter/keplergl/keplergl.py | 8 +------- bindings/kepler.gl-jupyter/requirements.txt | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/bindings/kepler.gl-jupyter/keplergl/keplergl.py b/bindings/kepler.gl-jupyter/keplergl/keplergl.py index be2f8a26db..1cc347c43b 100644 --- a/bindings/kepler.gl-jupyter/keplergl/keplergl.py +++ b/bindings/kepler.gl-jupyter/keplergl/keplergl.py @@ -3,7 +3,6 @@ from traitlets import Unicode, Dict, Int, validate, TraitError import pandas as pd import geopandas -import shapely.wkt import json from ._version import EXTENSION_SPEC_VERSION import sys @@ -34,14 +33,9 @@ def _gdf_to_dict(gdf): if gdf.crs and not gdf.crs == 4326: gdf = gdf.to_crs(4326) - # get name of the geometry column - # will cause error if data frame has no geometry column - name = gdf.geometry.name # convert geodataframe to dataframe - df = pd.DataFrame(gdf) - # convert geometry to wkt - df[name] = df.geometry.apply(lambda x: shapely.wkt.dumps(x)) + df = pd.DataFrame(gdf.to_wkt()) return _df_to_dict(df) diff --git a/bindings/kepler.gl-jupyter/requirements.txt b/bindings/kepler.gl-jupyter/requirements.txt index b78c442991..057a06ca3a 100644 --- a/bindings/kepler.gl-jupyter/requirements.txt +++ b/bindings/kepler.gl-jupyter/requirements.txt @@ -1,6 +1,5 @@ -geopandas==0.5.0 +geopandas==0.9.0 ipywidgets==7.4.2 pandas==0.24.2 -Shapely==1.6.4.post2 traitlets==4.3.2 traittypes==0.2.1