Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 22, 2023
1 parent 6373bd2 commit 528bf08
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ext/RastersMakieExt/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit 528bf08

Please sign in to comment.