Skip to content

Raster data (with Rasters.jl)

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, which also underpins e.g. 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.

julia
using Rasters, RasterDataSources, ArchGDAL

We'll also load GeoMakie and CairoMakie to plot the data.

julia
using GeoMakie, CairoMakie

First, we can load a Raster from the EarthEnv project, which represents habitat or ecosystem heterogeneity.

@example
ras = Raster(EarthEnv{HabitatHeterogeneity}, :homogeneity) # habitat homogeneity to neighbouring pixel

Let's take a look at this in regular Makie first:

@example
heatmap(ras; axis = (; aspect = DataAspect()))

We can plot this in any projection (but heatmap only works over a projection in CairoMakie, for all other backends use surface instead):

@example
fig, ga, hm = heatmap(ras; axis = (; type = GeoAxis))

We can also change the projection arbitrarily:

@example
ga.dest[] = "+proj=ortho +lon_0=19 +lat_0=72"
fig

and all other Makie keyword arguments and attributes also apply!

@example
hm.colormap = :isoluminant_cgo_70_c39_n256
fig

You can also use other recipes like surface:

@example
fig = Figure(); ga = GeoAxis(fig[1, 1])
sp = surface!(ga, ras)
fig

This looks a bit strange - but you can always disable shading:

@example
sp.shading = NoShading
fig

See also the Geostationary image and Multiple CRS examples, where we explore how to plot data in different projections.


This page was generated using Literate.jl.