Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Jun 7, 2024
1 parent ec75bed commit 5f18baa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
5 changes: 4 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ examples = [
"orthographic.jl",
"german_lakes.jl",
"geostationary_image.jl",
"multiple_crs.jl",
joinpath("gmt", "antioquia.jl"),
"contourf.jl",
"world_population.jl",
"field_and_countries.jl",
"meshimage.jl",
"projections.jl",
"tissot.jl",
"rotating_earth.jl",
joinpath("gmt", "antioquia.jl"),
"rasters.jl",

]
example_dir = joinpath(dirname(@__DIR__), "examples")
for filename in examples
Expand Down
35 changes: 34 additions & 1 deletion examples/rasters.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
# # Raster data (with Rasters.jl)
# [Rasters.jl](https://github.com/rafaqz/Rasters.jl) is a Julia package designed for working with raster data.
# It provides tools to read, write, and manipulate raster datasets,
# which are commonly used in geographic information systems (GIS),
# remote sensing, and similar fields where grid data is prevalent.
# It's built on top of [DimensionalData.jl](https://github.com/rafaqz/DimensionalData.jl), which also underpins e.g. [YAXArrays.jl](https://github.com/JuliaDataCubes/YAXArrays.jl).
#
# In general, any input that works with base Makie will work with GeoMakie in a GeoAxis!

# First, we'll load Rasters.jl, RasterDataSources.jl which provides access to common datasets, and ArchGDAL.jl which Rasters.jl depends on to read files.
using Rasters, RasterDataSources, ArchGDAL
# We'll also load GeoMakie and CairoMakie to plot the data.
using GeoMakie, CairoMakie

#
# First, we can load a Raster from the [EarthEnv](earthenv.org) project, which represents habitat or ecosystem heterogeneity.

ras = Raster(EarthEnv{HabitatHeterogeneity}, :homogeneity) # habitat homogeneity to neighbouring pixel
# Let's take a look at this in regular Makie first:
heatmap(ras; axis = (; aspect = DataAspect()))
# We can plot this in any projection:
fig = Figure(); ga = GeoAxis(fig[1, 1])
hm = heatmap!(ga, ras)
fig
# We can also change the projection arbitrarily:
ga.dest[] = "+proj=ortho +lon_0=19 +lat_0=72"
fig
# and all other Makie keyword arguments also apply!
hm.colormap = :isoluminant_cgo_70_c39_n256
fig
# You can also use other recipes like surface:
fig = Figure(); ga = GeoAxis(fig[1, 1])
sp = surface!(ga, ras)
fig
# This looks a bit strange - but you can always disable shading:
sp.shading = NoShading
fig
# See also the Geostationary image and Multiple CRS examples, where we explore how to plot data in different projections.
# make cover image #jl
mkpath("covers") #hide
save("covers/$(splitext(basename(@__FILE__))[1]).png", fig) #hide
Expand Down
4 changes: 0 additions & 4 deletions examples/source_crs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ webmerc_geojson = GO.reproject(GI.convert.((GI,), geojson) |> GO.tuples; transfo

london = Rect2d(-0.0921, 51.5, 0.04, 0.025)

function Makie.MakieCore.attribute_name_allowlist()
(:xautolimits, :yautolimits, :zautolimits, :label, :rasterize, :model, :transformation, :dest, :source, :specular, :matcap, :backlight, :shininess, :interpolate, :diffuse,:dim_conversions)
end

fig = Figure()
nax = Axis(fig[1, 1]; aspect = DataAspect())
m = Tyler.Map(london, figure = fig, axis = nax)
Expand Down

0 comments on commit 5f18baa

Please sign in to comment.