Skip to content

Conversation

@jiayuasu
Copy link
Member

@jiayuasu jiayuasu commented Feb 9, 2026

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

SedonaUtils.display_image() hangs when passed a raw raster DataFrame (e.g., 1400x800) because __convert_to_gdf_or_pdf__ attempts to Arrow-serialize the full GridCoverage2D object.

This PR adds raster UDT detection to display_image():

  • Detects raster columns via typeName() == "rastertype"
  • Auto-applies RS_AsImage() to each raster column before rendering
  • Preserves all non-raster columns in the DataFrame
  • Falls through to the existing __convert_to_gdf_or_pdf__ + to_html() path after conversion

Users can now pass a raw raster DataUsers can now pass a raw raster DataUsers can now pass a raw raster DataUsers this patch tested?

  • Tested manually in Jupyter notebook inside the Sedona Docker container
  • Verified with raw raster DataFrame (single and multi-column)
  • Verified with pre-applied RS_AsImage() DataFrame (regression check)
  • Existing test test_sedonautils.py::test_display_image continues to pass

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation. Updated docs/api/sql/Raster-visualizer.md to show both the new direct raster display (recommended) and the explicit RS_AsImage workflow.

@jiayuasu jiayuasu added this to the sedona-1.9.0 milestone Feb 9, 2026
@jiayuasu jiayuasu force-pushed the fix/2407-raster-jupyter-display branch 2 times, most recently from 9152305 to 031e9cb Compare February 9, 2026 07:50
@jiayuasu jiayuasu requested a review from Copilot February 9, 2026 07:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds auto-detection of raster columns in SedonaUtils.display_image() to avoid hangs when rendering raw raster DataFrames in notebooks, and updates docs to recommend the new workflow.

Changes:

  • Auto-detects raster UDT columns (typeName() == "rastertype") and applies RS_AsImage() before rendering.
  • Preserves non-raster columns while converting raster columns to HTML image output.
  • Updates raster documentation to show direct Jupyter rendering via SedonaUtils.display_image().

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/sedona/spark/raster_utils/SedonaUtils.py Adds raster-column detection and auto-RS_AsImage() projection inside display_image()
docs/tutorial/raster.md Adds tips recommending SedonaUtils.display_image() for quick Jupyter visualization
docs/api/sql/Raster-visualizer.md Expands Jupyter visualization section and documents direct raster display workflow
docs/api/sql/Raster-operators.md Adds tip pointing to SedonaUtils.display_image() for quick visualization
docs/api/sql/Raster-map-algebra.md Adds tip for inspecting map algebra results via display_image()
docs/api/sql/Raster-loader.md Adds tip for visualizing loaded rasters via display_image()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jiayuasu jiayuasu force-pushed the fix/2407-raster-jupyter-display branch from 031e9cb to a9dc13c Compare February 9, 2026 09:46
@jiayuasu jiayuasu requested a review from Copilot February 9, 2026 10:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

SedonaUtils.display_image() was slow for raster DataFrames because it
routed through SedonaMapUtils.__convert_to_gdf_or_pdf__(), which performs
Arrow conversion, geopandas import attempts, and DataFrame-to-HTML-table
wrapping — all unnecessary when the input is already HTML <img> strings
from RS_AsImage().

- Add fast path: collect rows directly and render HTML <img> strings
  without intermediate Arrow/Pandas/to_html() conversion
- Keep fallback to original path for non-image DataFrames
- Add docstring to display_image()
@jiayuasu jiayuasu force-pushed the fix/2407-raster-jupyter-display branch from a9dc13c to 94fa858 Compare February 9, 2026 10:21
@jiayuasu jiayuasu merged commit 59fc2e0 into master Feb 9, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Rendering image in jupyter notebook using SedonaUtils, display_image takes long time

1 participant