diff --git a/src/spatialdata_plot/pl/utils.py b/src/spatialdata_plot/pl/utils.py index b6eab503..25720fb5 100644 --- a/src/spatialdata_plot/pl/utils.py +++ b/src/spatialdata_plot/pl/utils.py @@ -2283,6 +2283,10 @@ def _rasterize_if_necessary( coordinate_system, target_unit_to_pixels=target_unit_to_pixels, ) + if hasattr(image.data, "compute"): + # rasterize is lazy; downstream reads the result once per channel (NaN check, + # compositing, draw), so materialize once instead of re-running the warp each time. + image = image.copy(data=image.data.compute()) return image