![]() |
Quetzal-CoaTL
The Coalescence Template Library
|
#include <quetzal/geography/raster.hpp>
Discrete spatio-temporal variations of an environmental variable.
Read and write georeferenced raster datasets with multiple bands (layers). Multiple rasters can be assembled into a multivariate discrete quetzal::geography::landscape.
Public Types | |
using | time_type = Time |
using | time_descriptor = std::vector< time_type >::size_type |
using | location_descriptor = int |
using | latlon = quetzal::geography::latlon |
using | lonlat = quetzal::geography::lonlat |
using | colrow = quetzal::geography::colrow |
using | rowcol = quetzal::geography::rowcol |
using | decimal_degree = double |
using | value_type = double |
Public Member Functions | |
raster (const std::filesystem::path &file, const std::vector< time_type > ×) | |
Constructor. | |
Spatial Grid properties | |
latlon | origin () const noexcept |
Origin of the spatial grid. | |
geography::resolution< decimal_degree > | get_resolution () const noexcept |
Resolution of the spatial grid. | |
geography::extent< decimal_degree > | get_extent () const noexcept |
Extent of the spatial grid. | |
int | width () const noexcept |
Width of the spatial grid. | |
int | height () const noexcept |
Height of the spatial grid. | |
int | depth () const noexcept |
Depth of the spatial grid. | |
value_type | NA () const noexcept |
NA value, as read in the first band of the dataset. | |
Look-up | |
auto | locations () const noexcept |
Location descriptors (unique identifiers) of the grid cells. | |
auto | times () const noexcept |
Time descriptors (unique identifiers) of the dataset bands. | |
bool | is_valid (location_descriptor x) const noexcept |
Check if a descriptor describes a valid location of the spatial grid. | |
bool | is_valid (const colrow &x) const noexcept |
Check if the coordinate describes a valid location of the spatial grid. | |
bool | is_valid (const rowcol &x) const noexcept |
Check if the coordinate describes a valid location of the spatial grid. | |
bool | contains (const latlon &x) const noexcept |
Check if the raster contains a coordinate. | |
bool | contains (const lonlat &x) const noexcept |
Check if the raster contains a coordinate. | |
bool | is_valid (time_descriptor t) const noexcept |
Check if the time descriptor is a valid index. | |
bool | is_recorded (const time_type &t) const noexcept |
Search for the exact time in the list of time points recorded by the raster. | |
bool | is_in_interval (const time_type &t) const noexcept |
Check if the exact time point falls between the first and last date of record. | |
std::optional< value_type > | at (location_descriptor x, time_descriptor t) const noexcept |
Read the value at location x and time t. | |
auto | to_view () const noexcept |
Makes the raster a callable with signature std::optional<value_type> (location_descriptor x, time_descriptor t) returning the value at location x and time t. | |
Coordinate systems | |
location_descriptor | to_descriptor (const colrow &x) const noexcept |
Location descriptor of the cell identified by its column/row. | |
location_descriptor | to_descriptor (const latlon &x) const noexcept |
Location descriptor of the cell to which the given coordinate belongs. | |
colrow | to_colrow (const latlon &x) const noexcept |
Column and row of the cell to which the given coordinate belongs. | |
rowcol | to_rowcol (const latlon &x) const noexcept |
Row and column of the cell to which the given coordinate belongs. | |
colrow | to_colrow (location_descriptor x) const noexcept |
Column and row of the cell to which the given descriptor belongs. | |
rowcol | to_rowcol (location_descriptor x) const noexcept |
Column and row of the cell to which the given descriptor belongs. | |
latlon | to_latlon (location_descriptor x) const noexcept |
Latitude and longitude of the cell to which the given coordinate belongs. | |
lonlat | to_lonlat (location_descriptor x) const noexcept |
Latitude and longitude of the cell to which the given coordinate belongs. | |
latlon | to_latlon (const colrow &x) const noexcept |
Latitude and longitude of the cell identified by its column/row. | |
latlon | to_latlon (const rowcol &x) const noexcept |
Latitude and longitude of the cell identified by its row/column. | |
lonlat | to_lonlat (const colrow &x) const noexcept |
Longitude and latitude of the deme identified by its column/row. | |
latlon | to_centroid (const latlon &x) const |
Reprojects a coordinate to the centroid of the cell it belongs. | |
Input/Output | |
template<class Callable > requires (std::is_invocable_r_v<std::optional<value_type>, Callable, location_descriptor, time_type>) | |
void | to_geotiff (Callable f, time_type start, time_type end, const std::filesystem::path &file) const |
Export a spatio-temporal raster to a Geotiff file. | |
void | to_shapefile (std::vector< latlon > points, const std::filesystem::path &file) const |
Export spatial points to a shapefile. | |
void | to_shapefile (std::map< latlon, int > counts, const std::filesystem::path &file) const |
Export geolocalized counts as spatial-points to a shapefile. | |
std::ostream & | write (std::ostream &stream) const |
Raster is streamable. | |
static raster | from_file (const std::filesystem::path &file, const std::vector< time_type > ×) |
Read the raster from an input file in the geotiff format. | |
|
inlineexplicit |
Constructor.
file | the raster dataset file to read. |
times | the time period of each layer |
|
inlinenoexcept |
Read the value at location x and time t.
x | the location |
t | the time |
|
inlinenoexcept |
Check if the raster contains a coordinate.
x | the lat/lon to check. |
|
inlinenoexcept |
Check if the raster contains a coordinate.
x | the lon/lat to check. |
|
inlinestatic |
Read the raster from an input file in the geotiff format.
file | The file to read from |
times | The time periods relative to each band. |
|
inlinenoexcept |
Resolution of the spatial grid.
|
inlinenoexcept |
Check if the exact time point falls between the first and last date of record.
t | An exact point in time |
|
inlinenoexcept |
Search for the exact time in the list of time points recorded by the raster.
t | An exact point in time |
|
inlinenoexcept |
Check if the coordinate describes a valid location of the spatial grid.
x | the column/row to check. |
|
inlinenoexcept |
Check if the coordinate describes a valid location of the spatial grid.
x | the row/column to check. |
|
inlinenoexcept |
Check if a descriptor describes a valid location of the spatial grid.
x | the descriptor to check |
|
inlinenoexcept |
Check if the time descriptor is a valid index.
t | A time descriptor identifying a band of the raster dataset. |
|
inlinenoexcept |
Location descriptors (unique identifiers) of the grid cells.
|
inlinenoexcept |
Time descriptors (unique identifiers) of the dataset bands.
|
inline |
Reprojects a coordinate to the centroid of the cell it belongs.
x | The location to reproject |
|
inlinenoexcept |
Column and row of the cell to which the given coordinate belongs.
x | the latitude/longitude coordinate to evaluate. |
|
inlinenoexcept |
Column and row of the cell to which the given descriptor belongs.
x | the location to evaluate. |
|
inlinenoexcept |
Location descriptor of the cell identified by its column/row.
x | the 1D coordinate to evaluate. |
|
inlinenoexcept |
Location descriptor of the cell to which the given coordinate belongs.
x | the latitude/longitude coordinate to evaluate. |
|
inline |
Export a spatio-temporal raster to a Geotiff file.
f | functor defining the variable: its signature should be equivalent to std::optional<double> f(location_descriptor, time_descriptor) |
start | the first time_descriptor value where f should be called. |
end | the last time_descriptor value where f should be called. |
file | the file name where to save |
|
inlinenoexcept |
Latitude and longitude of the cell identified by its column/row.
x | the location to evaluate. |
|
inlinenoexcept |
Latitude and longitude of the cell identified by its row/column.
x | the location to evaluate. |
|
inlinenoexcept |
Latitude and longitude of the cell to which the given coordinate belongs.
x | the location to evaluate. |
|
inlinenoexcept |
Longitude and latitude of the deme identified by its column/row.
x | the location to evaluate. |
|
inlinenoexcept |
Latitude and longitude of the cell to which the given coordinate belongs.
x | the location to evaluate. |
|
inlinenoexcept |
Row and column of the cell to which the given coordinate belongs.
x | the latitude/longitude coordinate to evaluate. |
|
inlinenoexcept |
Column and row of the cell to which the given descriptor belongs.
x | the location to evaluate. |
|
inline |
Export geolocalized counts as spatial-points to a shapefile.
counts the number of points at every point
file the path to write to.
|
inline |
Export spatial points to a shapefile.
points | the points to export |
file | the path to write to |
|
inlinenoexcept |
Makes the raster a callable with signature std::optional<value_type> (location_descriptor x, time_descriptor t)
returning the value at location x and time t.
quetzal::expressive