This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new e69b5302c [SEDONA-581] SedonaKepler fails to reload if a raster column 
exists (#1445)
e69b5302c is described below

commit e69b5302c29c91a46aebeda2dbfd178978945e2c
Author: Furqaan Khan <[email protected]>
AuthorDate: Thu May 30 18:13:37 2024 -0400

    [SEDONA-581] SedonaKepler fails to reload if a raster column exists (#1445)
---
 python/sedona/maps/SedonaKepler.py                   |  6 ++++++
 python/tests/maps/test_sedonakepler_visualization.py | 11 ++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/python/sedona/maps/SedonaKepler.py 
b/python/sedona/maps/SedonaKepler.py
index 113699258..0b3530826 100644
--- a/python/sedona/maps/SedonaKepler.py
+++ b/python/sedona/maps/SedonaKepler.py
@@ -16,6 +16,7 @@
 #  under the License.
 
 from sedona.maps.SedonaMapUtils import SedonaMapUtils
+from sedona.sql.types import RasterType
 
 
 class SedonaKepler:
@@ -54,5 +55,10 @@ class SedonaKepler:
         :param name: [Optional] Name to assign to the dataframe, default name 
assigned is 'unnamed'
         :return: Does not return anything, adds df directly to the given map 
object
         """
+        schema = df.schema
+        for field in schema.fields:
+            if field.dataType == RasterType():
+                df = df.drop(field.name)
+
         geo_df = SedonaMapUtils.__convert_to_gdf_or_pdf__(df)
         kepler_map.add_data(geo_df, name=name)
diff --git a/python/tests/maps/test_sedonakepler_visualization.py 
b/python/tests/maps/test_sedonakepler_visualization.py
index fc8ae321a..e681873a9 100644
--- a/python/tests/maps/test_sedonakepler_visualization.py
+++ b/python/tests/maps/test_sedonakepler_visualization.py
@@ -18,7 +18,7 @@
 from keplergl import KeplerGl
 from sedona.maps.SedonaKepler import SedonaKepler
 from tests.test_base import TestBase
-from tests import mixed_wkt_geometry_input_location
+from tests import mixed_wkt_geometry_input_location, 
world_map_raster_input_location
 from tests import csv_point_input_location
 import geopandas as gpd
 from pyspark.sql.functions import explode, hex
@@ -50,6 +50,15 @@ class TestVisualization(TestBase):
         assert sedona_kepler_map._repr_html_() == kepler_map._repr_html_()
         assert sedona_kepler_map.config == kepler_map.config
 
+    def test_df_with_raster(self):
+        df = 
self.spark.read.format("binaryFile").load(world_map_raster_input_location)
+        df = df.selectExpr("RS_FromGeoTiff(content) as raster", 
"ST_GeomFromWKT('POINT (1 1)') as point")
+
+        sedona_kepler = SedonaKepler.create_map(df=df, name="data_1")
+        actual = sedona_kepler.data
+        expected = {'data_1': {'index': [0], 'columns': ['geometry'], 'data': 
[['POINT (1.0000000000000000 1.0000000000000000)']]}}
+        assert actual == expected
+
     def test_df_addition(self):
         polygon_wkt_df = self.spark.read.format("csv"). \
             option("delimiter", "\t"). \

Reply via email to