Importing and exporting your own data

It is possible to import your own rasters into a SimpleSDMLayer object and to export SimpleSDMLayer objects to raster files. In this example, we will look at a data file produced by the OmniScape package, and which represents landscape connectivity in the Laurentians region of Québec. This example will also show how we can use the broadcast operation to modify the values of a raster.

Importing data

using SimpleSDMLayers
using Plots
using StatsBase

The file comes with the package itself, so we can read it directly - this is a geotiff file, where values are floating point numbers representing connectivity.

file = joinpath(dirname(pathof(SimpleSDMLayers)), "..", "data", "connectivity.tiff")
"/home/runner/work/SimpleSDMLayers.jl/SimpleSDMLayers.jl/src/../data/connectivity.tiff"

To import this file as a SimpleSDMLayer, we need to call the geotiff function, which assumes a WGS84 projection:

mp = geotiff(SimpleSDMPredictor, file)
SDM predictor → 1255×1205 grid with 863533 Float32-valued cells
  Latitudes	(45.34604248605578, 47.38375751394422)
  Longitudes	(-75.17617396351575, -72.36835810945273)

Because this file has raw values, which are not necessarily great for plotting, we will transform it to quantiles, using the rescale function.

qmap = rescale!(mp, collect(0.0:0.01:1.0))
SDM predictor → 1255×1205 grid with 863533 Float32-valued cells
  Latitudes	(45.34604248605578, 47.38375751394422)
  Longitudes	(-75.17617396351575, -72.36835810945273)

Finally, we are ready for plotting:

plot(qmap, frame=:grid, c=:cork, clim=(0,1))