Skip to content

Commit

Permalink
[SEDONA-556] Hidden requirement for geopandas in apache-sedona 1.5.2 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayuasu committed May 9, 2024
1 parent 01d5940 commit d6b3b6a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/sedona/maps/SedonaMapUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -38,6 +36,11 @@ def __convert_to_gdf_or_pdf__(cls, df, rename=True, geometry_col=None):
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)
Expand Down

0 comments on commit d6b3b6a

Please sign in to comment.