This is an automated email from the ASF dual-hosted git repository. jiayu pushed a commit to branch kepler_to_pandas in repository https://gitbox.apache.org/repos/asf/sedona.git
commit 6392dbd522883aa0043b6b928bc6fa9fb55aeb94 Author: Jia Yu <[email protected]> AuthorDate: Thu Feb 6 10:47:44 2025 -0800 Initial commit --- python/sedona/maps/SedonaMapUtils.py | 10 +++++++++- python/sedona/raster_utils/SedonaUtils.py | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/python/sedona/maps/SedonaMapUtils.py b/python/sedona/maps/SedonaMapUtils.py index 66fa283d1d..fd9ca7dedf 100644 --- a/python/sedona/maps/SedonaMapUtils.py +++ b/python/sedona/maps/SedonaMapUtils.py @@ -17,7 +17,10 @@ import json +import geopandas + from sedona.sql.types import GeometryType +from sedona.utils.geoarrow import dataframe_to_arrow class SedonaMapUtils: @@ -34,7 +37,12 @@ class SedonaMapUtils: """ if geometry_col is None: geometry_col = SedonaMapUtils.__get_geometry_col__(df) - pandas_df = df.toPandas() + + # Convert the dataframe to arrow format, then to geopandas dataframe + # This is faster than converting directly to geopandas dataframe via toPandas + data_pyarrow = dataframe_to_arrow(df) + pandas_df = geopandas.GeoDataFrame.from_arrow(data_pyarrow) + if ( geometry_col is None ): # No geometry column found even after searching schema, return Pandas Dataframe diff --git a/python/sedona/raster_utils/SedonaUtils.py b/python/sedona/raster_utils/SedonaUtils.py index 5f7304f3ff..fcff45756f 100644 --- a/python/sedona/raster_utils/SedonaUtils.py +++ b/python/sedona/raster_utils/SedonaUtils.py @@ -15,10 +15,18 @@ # specific language governing permissions and limitations # under the License. +import geopandas + +from sedona.utils.geoarrow import dataframe_to_arrow + class SedonaUtils: @classmethod def display_image(cls, df): from IPython.display import HTML, display - display(HTML(df.toPandas().to_html(escape=False))) + # Convert the dataframe to arrow format, then to geopandas dataframe + # This is faster than converting directly to geopandas dataframe via toPandas + data_pyarrow = dataframe_to_arrow(df) + pdf = geopandas.GeoDataFrame.from_arrow(data_pyarrow) + display(HTML(pdf.to_html(escape=False)))
