Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example of how to use Healpix.jl with GeoMakie. #246

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ Geodesy = "0ef565a4-170c-5f04-8de2-149903a85f3d"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
GeometryOps = "3251bfac-6a57-4b6d-aa61-ac1fef2975ab"
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
Healpix = "9f4e344d-96bc-545a-84a3-ae6b9e1b672b"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ examples = String[
"geostationary_image.jl",
"multiple_crs.jl",
"rasters.jl",
"healpix.jl",
"is_it_a_plane.jl",
joinpath("cartopy", "annotation.jl"),
joinpath("cartopy", "katrina.jl"),
1 change: 1 addition & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ german_lakes
meshimage
projections
tissot
healpix
```

## Examples from Cartopy
45 changes: 45 additions & 0 deletions examples/healpix.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#=
# Healpix.jl

[Healpix.jl](https://github.com/ziotom78/Healpix.jl) is an equal-area "pixelization" of the 2-sphere. Here, we show how to plot a Healpix.jl pixelization via GeoMakie.

This is currently a manual process, but we hope to add recipes soon!

=#

# Construct a synthetic Healpix map

using CairoMakie, GeoMakie

using Healpix
nside = 8
m = HealpixMap{Float64, RingOrder}(nside)
m.pixels[:] = 1:length(m.pixels)
m
#
img, _, _ = Healpix.equirectangular(m)
heatmap(img)
# Now we can plot it on a GeoAxis with a Mollweide projection:
meshimage(-180..180, -90..90, reverse(img; dims = 1); npoints = 200, axis = (; type = GeoAxis, dest = "+proj=moll"))
# Finally, we can also try to obtain the image as a Mollweide projected image via Healpix, and then plot it directly.
# For more information on what we're doing here, see the [Multiple CRS](@ref) example.
img, _, _ = Healpix.mollweide(m)
heatmap(img)
#
fig = Figure()
ax = GeoAxis(fig[1, 1]; dest = "+proj=moll")
hp_bbox = Makie.apply_transform(ax.transform_func[], Makie.BBox(-180, 180, -90, 90))
# The rectangle above is the bounding box of the full Earth (or sky, in this case) in the Mollweide projection.
mini = minimum(hp_bbox)
maxi = maximum(hp_bbox)
meshimage!(ax, mini[1]..maxi[1], mini[2]..maxi[2], reverse(img; dims = 1); npoints = 200, source = "+proj=moll")
lines!(ax, GeoMakie.coastlines(); color = :black, xautolimits = false, yautolimits = false)
fig
# Note how the meshimage looks a bit pixelated there - that is because of the mollweide projection!

#=
```@cardmeta
Description = "Spherical pixelizations from Healpix.jl"
Cover=fig
```
=#