Once users have simulated various continuous geospatial values such as friction coefficients or population sizes across a landscape, they will often desire a visual confirmation of these values. One approach is to export these quantities as a multiband raster file and utilize different software, such as Quetzal-CRUMBS or the raster
package in R, for visualization.
To export a specific quantity, it is necessary to create a callable function that can be invoked at each location within the raster model during an arbitrary time interval. Each point of the time interval parameter will become a new band in the new raster file.
Input
1#include "quetzal/geography.hpp"
10 using time_type = int;
12 using location_descriptor =
typename raster_type::location_descriptor;
15 std::vector<time_type> times(10);
16 std::iota(times.begin(), times.end(), 2001);
18 auto input_file = std::filesystem::current_path() /
"data/bio1.tif";
21 auto bio1 = raster_type::from_file(input_file, times);
24 auto transform = [](location_descriptor x, time_type t) {
return std::optional(2 * x + t); };
27 auto output_file = std::filesystem::current_path() /
"my_quantity.tif";
30 bio1.to_geotiff(transform, 2001, 2005, output_file);
32 std::cout << (std::filesystem::exists(
"my_quantity.tif") ?
"success" :
"error") << std::endl;
35 std::filesystem::remove_all(output_file);
Discrete spatio-temporal variations of an environmental variable.
Definition raster.hpp:38
Simulation of coalescence-based models of molecular evolution.
Definition coalescence.hpp:21
Output