Skip to content

Commit

Permalink
Draft of vignette on stats
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisot committed Nov 15, 2022
1 parent 65bc3c8 commit 3f85e8f
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions docs/src/vignettes/07_statistics_on_layers.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# # Statistics on layers

using SpeciesDistributionToolkit
using CairoMakie
using Statistics

# ...

spatial_extent = (left = 3.032, bottom = 55.178, right = 19.687, top = 64.717)

#

rangifer = taxon("Rangifer tarandus tarandus"; strict = false)
query = [
"occurrenceStatus" => "PRESENT",
"hasCoordinate" => true,
"country" => "NO",
"country" => "SE",
"country" => "FI",
"country" => "DE",
]
presences = occurrences(rangifer, query...)

# layers

dataprovider = RasterData(CHELSA1, BioClim)
temperature = 0.1SimpleSDMPredictor(dataprovider; layer = "BIO1", spatial_extent...)
precipitation = 1.0SimpleSDMPredictor(dataprovider; layer = "BIO12", spatial_extent...)

#

mean(temperature)

#

std(temperature)

#

z_temperature = (temperature - mean(temperature)) / std(temperature)

#

fig, ax, hm = heatmap(
sprinkle(z_temperature)...;
colormap = :roma,
colorrange = (-2, 2),
figure = (; resolution = (800, 400)),
axis = (; aspect = DataAspect()),
)
Colorbar(fig[:, end + 1], hm)
current_figure()

#

fig, ax, hm = heatmap(
sprinkle(rescale(precipitation, (0.0, 1.0)))...;
colormap = :bamako,
figure = (; resolution = (800, 400)),
axis = (; aspect = DataAspect()),
)
Colorbar(fig[:, end + 1], hm)
current_figure()

#

fig, ax, hm = heatmap(
sprinkle(rescale(precipitation, collect(0.0:0.05:1.0)))...;
colormap = :bamako,
figure = (; resolution = (800, 400)),
axis = (; aspect = DataAspect()),
)
Colorbar(fig[:, end + 1], hm)
current_figure()

#

quantile(temperature, [0.05, 0.95])

0 comments on commit 3f85e8f

Please sign in to comment.