You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2025/02/06 18:47:56 UTC
(sedona) branch kepler_to_pandas created (now 6392dbd522)
This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a change to branch kepler_to_pandas
in repository https://gitbox.apache.org/repos/asf/sedona.git
at 6392dbd522 Initial commit
This branch includes the following new commits:
new 6392dbd522 Initial commit
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(sedona) 01/01: Initial commit
Posted by ji...@apache.org.
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 <ji...@apache.org>
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)))