From 528bf080e07bba2f0e0729e6cb7051d2585f1059 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sun, 22 Oct 2023 15:51:31 +0200 Subject: [PATCH] f --- ext/RastersMakieExt/plotrecipes.jl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ext/RastersMakieExt/plotrecipes.jl b/ext/RastersMakieExt/plotrecipes.jl index f17546e46..c851da237 100644 --- a/ext/RastersMakieExt/plotrecipes.jl +++ b/ext/RastersMakieExt/plotrecipes.jl @@ -309,6 +309,22 @@ function Makie.plottype(raster::AbstractRaster{<:Union{Missing,Real},3}) Makie.Volume end end + +function Makie.convert_arguments(t::Makie.PointBased, A::AbstractRaster{<:Any,1}) + return Makie.convert_arguments(t, _prepare_dimarray(A)) +end +function Makie.convert_arguments(t::Makie.PointBased, A::AbstractRaster{<:Number,2}) + return Makie.convert_arguments(t, _prepare_dimarray(A)) +end +function Makie.convert_arguments(t::Makie.SurfaceLike, A::AbstractRaster{<:Any,2}) + return Makie.convert_arguments(t, _prepare_dimarray(A)) +end +function Makie.convert_arguments(t::Makie.DiscreteSurface, A::AbstractRaster{<:Any,2}) + return Makie.convert_arguments(t, _prepare_dimarray(A)) +end +function Makie.convert_arguments(t::Makie.VolumeLike, A::AbstractRaster{<:Any,3}) + return Makie.convert_arguments(t, _prepare_dimarray(A)) +end # allow plotting 3d rasters with singleton third dimension (basically 2d rasters) function Makie.convert_arguments(x::Makie.ConversionTrait, raster::AbstractRaster{<:Union{Real,Missing},3}) D = _series_dim(raster) @@ -328,3 +344,9 @@ function _series_dim(A) spatialdims = (X(), Y(), Z()) last((dims(A, spatialdims)..., otherdims(A, spatialdims)...)) end + +function _prepare_dimarray(A) + map(A) do x + isequal(x, missingval(A)) || ismissing(x) ? NaN32 : Float32(x) + end |> DimArray +end