Skip to content

Commit

Permalink
fix makie for RGB rasters (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz authored Oct 28, 2023
1 parent ffa56ec commit f9818c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
RasterDataSources = "3cb90ccd-e1b6-4867-9617-4276c8b2ca36"
Expand All @@ -76,7 +75,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "ArchGDAL", "CFTime", "CoordinateTransformations", "DataFrames", "GeometryBasics", "HDF5", "MakieCore", "NCDatasets", "Plots", "RasterDataSources", "SafeTestsets", "Shapefile", "Statistics", "Test"]
test = ["Aqua", "ArchGDAL", "CFTime", "CoordinateTransformations", "DataFrames", "GeometryBasics", "HDF5", "NCDatasets", "Plots", "RasterDataSources", "SafeTestsets", "Shapefile", "Statistics", "Test"]

[weakdeps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand Down
9 changes: 4 additions & 5 deletions ext/RastersMakieExt/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ function _series_dim(A)
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
_prepare_dimarray(A) = DimArray(map(x -> _convert_with_missing(x, missingval(A)), A))

_convert_with_missing(x::Real, missingval) = isequal(x, missingval) || ismissing(x) ? NaN32 : Float32(x)
_convert_with_missing(x, missingval) = isequal(x, missingval) ? missing : x
7 changes: 6 additions & 1 deletion test/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if !haskey(ENV, "CI")
ys = -20.0:1.0:20.0
rast = Raster(rand(X(xs), Y(ys)))

using Makie
using GLMakie
# Some small diversions from the DimensionalData.jl recipes
@test Makie.convert_arguments(Makie.DiscreteSurface(), rast) ==
(lookup(rast, X), lookup(rast, Y), Float32.(rast.data))
Expand All @@ -74,4 +74,9 @@ if !haskey(ENV, "CI")
Makie.heatmap(ga3)
Rasters.rplot(ga2)
Rasters.rplot(ga3)

using Colors
c = Raster(rand(RGB, X(10), Y(10)))
Makie.image(c)
# Makie.heatmap(c) # Doesn't work because of the auto Colorbar
end

0 comments on commit f9818c6

Please sign in to comment.