danlooo / DGGS.jl

Discrete Global Grid System for Julia
GNU Affero General Public License v3.0
8 stars 2 forks source link

How to include plot functionalities #26

Closed danlooo closed 7 months ago

danlooo commented 1 year ago

How to provide a function for easy plotting w/o bloating the package dependencies and allowing to modify the plot later on?

function plot_map(geo_cube::GeoCube)
    # Can not use Makie plot recipies, because we need to specify the axis for GeoMakie
    # see https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006

    fig = Figure()
    ax = GeoAxis(fig[1, 1]; dest="+proj=wintri", coastlines=true)
    plt = surface!(ax, geo_cube.longitudes, geo_cube.latitudes, geo_cube.data.data; colormap=:viridis, shading=false)
    cb1 = Colorbar(fig[1, 2], plt; label="Value", height=Relative(0.5))
    return fig
end

function plot_map(cell_cube::CellCube)
    # raster cellcube, because geo coordinates needed for plotting
    geo_cube = GeoCube(cell_cube)
    plot_map(geo_cube)
end
danlooo commented 1 year ago

Use Julia Weak Dependencies and Package extensions