This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch branch-1.5.2
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/branch-1.5.2 by this push:
new d6b3b6a30 [SEDONA-556] Hidden requirement for geopandas in
apache-sedona 1.5.2 (#1405)
d6b3b6a30 is described below
commit d6b3b6a303dde812c709a815d05eecd63e28d0af
Author: Jia Yu <[email protected]>
AuthorDate: Wed May 8 17:56:36 2024 -0700
[SEDONA-556] Hidden requirement for geopandas in apache-sedona 1.5.2 (#1405)
---
python/sedona/maps/SedonaMapUtils.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/python/sedona/maps/SedonaMapUtils.py
b/python/sedona/maps/SedonaMapUtils.py
index 5ab875d83..52cc47402 100644
--- a/python/sedona/maps/SedonaMapUtils.py
+++ b/python/sedona/maps/SedonaMapUtils.py
@@ -15,8 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-
-import geopandas as gpd
import json
from sedona.sql.types import GeometryType
@@ -38,6 +36,11 @@ class SedonaMapUtils:
pandas_df = df.toPandas()
if geometry_col is None: # No geometry column found even after
searching schema, return Pandas Dataframe
return pandas_df
+ try:
+ import geopandas as gpd
+ except ImportError:
+ msg = "GeoPandas is missing. You can install it manually or via
sedona[kepler-map] or sedona[pydeck-map]."
+ raise ImportError(msg) from None
geo_df = gpd.GeoDataFrame(pandas_df, geometry=geometry_col)
if geometry_col != "geometry" and rename is True:
geo_df.rename_geometry("geometry", inplace=True)