Skip to content

Commit

Permalink
Add an example of how to use Healpix.jl with GeoMakie. (#246)
Browse files Browse the repository at this point in the history
* Add an example of how to use Healpix.jl with GeoMakie.

* Add the example to make.jl, overview to examples.md, cardmeta

* Correct some oversights
  • Loading branch information
asinghvi17 authored Jun 19, 2024
1 parent b7c0fdd commit 5460701
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ german_lakes
meshimage
projections
tissot
healpix
```

## Examples from Cartopy
Expand Down
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
```
=#

0 comments on commit 5460701

Please sign in to comment.