Basics: elevation data

In this example, we will look at elevation data from the worldclim 2 data, crop it for Western Europe, and then change the resolution to aggregate the data. The first step is to get the worldclim layer for elevation:

using SimpleSDMLayers
using StatsPlots
import Statistics
elevation = convert(Float32, SimpleSDMPredictor(WorldClim, Elevation))
SDM response → 1080×2160 grid with 808053 Float32-valued cells
  Latitudes	-90.0 ⇢ 90.0
  Longitudes	-180.0 ⇢ 180.0

Thanks to the integration with Plots and StatsPlots, we can very rapidly visualize these data:

heatmap(elevation, c=:cividis, frame=:box)

Let's also have a look at the density while we're at it:

density(elevation, frame=:zerolines, c=:grey, fill=(0, :grey, 0.2), leg=false)

The next step is to clip the data to the region of interest. This requires a the coordinates of the bounding box as two tuples (for longitude and latitude) – we can also make a quick heatmap to see what the region looks like:

elevation_europe = clip(elevation; left=-11.0, right=31.5, bottom=29.0, top=71.5)
SDM response → 255×255 grid with 38507 Float32-valued cells
  Latitudes	29.0 ⇢ 71.5
  Longitudes	-11.0 ⇢ 31.5
heatmap(elevation_europe, c=:cividis, aspectratio=1, frame=:box)