| Title: | Remote Sensing Lake Data |
|---|---|
| Description: | Download and process ESA Sentinel-2 L2A data to obtain trophic state information or other satellite based indexes. |
| Authors: | Malte Zamzow [aut, cre] (ORCID: <https://orcid.org/0000-0002-8748-038X>), Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
| Maintainer: | Malte Zamzow <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-26 08:26:43 UTC |
| Source: | https://github.com/KWB-R/lakeRS |
Adds a human-readable lake name and a stable lake identifier to a list created
by seasonal_index_per_lake(). If no identifier is supplied, an identifier is
generated from the mean x and y coordinates of the lake grid.
add_lakeID(lakeIndex, lakeName = NULL, lakeID = NULL)add_lakeID(lakeIndex, lakeName = NULL, lakeID = NULL)
lakeIndex |
A list containing lake-level index results and at least the
coordinate vectors |
lakeName |
Optional character scalar with the lake name. If |
lakeID |
Optional character scalar with a unique lake identifier. If
|
The input list with two additional elements: Name and ID.
Calculates the north, east, south, and west limits of a square-like bounding box around a point in WGS 84 coordinates. The limits are computed by moving a fixed geodesic distance from the point in the four cardinal directions.
bbox_from_point(lat, lon, meters = 20)bbox_from_point(lat, lon, meters = 20)
lat |
Numeric scalar. Latitude of the center point in WGS 84
( |
lon |
Numeric scalar. Longitude of the center point in WGS 84
( |
meters |
Numeric scalar greater than zero. Distance in meters from the
point to each side of the bounding box. Default is |
A named numeric vector with elements north, east, south, and
west, suitable for start_openEO_job() or display_geometry().
Expands a latitude-longitude rectangle by a geodesic buffer distance and returns the resulting north, east, south, and west limits.
bbox_from_rectangle(top_lat, bottom_lat, left_lon, right_lon, meters = 20)bbox_from_rectangle(top_lat, bottom_lat, left_lon, right_lon, meters = 20)
top_lat |
Numeric scalar. Northern latitude of the rectangle in WGS 84
( |
bottom_lat |
Numeric scalar. Southern latitude of the rectangle in WGS 84
( |
left_lon |
Numeric scalar. Western longitude of the rectangle in WGS 84
( |
right_lon |
Numeric scalar. Eastern longitude of the rectangle in WGS 84
( |
meters |
Numeric scalar greater than zero. Buffer distance in meters.
Default is |
A named numeric vector with elements north, east, south, and
west.
Runs k-means clustering for increasing numbers of clusters and recommends the largest number that still satisfies a minimum cluster-size criterion. The decision is based on the proportion of variance explained by the clustering.
best_nk( pixelDynamic, kMax = 10, minimum_clusterSize = 0.01, correlate_first = FALSE )best_nk( pixelDynamic, kMax = 10, minimum_clusterSize = 0.01, correlate_first = FALSE )
pixelDynamic |
A list or data-frame-like object of pixel-level annual
dynamics, usually |
kMax |
Integer. Maximum number of clusters to test. Default is |
minimum_clusterSize |
Numeric. Minimum allowed cluster size expressed as
a proportion of all clustered pixels. Default is |
correlate_first |
Logical. If |
At most 10,000 pixels are sampled before testing cluster counts. If
correlate_first = TRUE, the selected pixels are correlated with at most
1,000 reference pixels. See prepare_for_clustering() for details on NA
handling and optional correlation pre-processing.
Integer giving the recommended number of clusters. The function also draws a diagnostic plot of explained variance by number of clusters.
Combines multiple annual outputs from dynamic_per_pixel() into summary
curves across years. For each day of year, the function averages the annual
median lake dynamics and calculates the standard deviation across those annual
medians.
combine_years_dynamic(indexDynamicList, years = NULL)combine_years_dynamic(indexDynamicList, years = NULL)
indexDynamicList |
A named or unnamed list of annual dynamic objects
created by |
years |
Optional numeric vector of years to include. If |
All selected dynamics must have been computed with the same
days_around_ma; otherwise the function stops because the smoothing windows
are not comparable.
A list with mean_of_median and sd_over_median, each a numeric
vector with one value per day of year.
Converts a list of annual lake index objects into a wide table with one row per lake and one index column per year.
combine_years_lakeData(lakeIndexList, aggregationType = "modus")combine_years_lakeData(lakeIndexList, aggregationType = "modus")
lakeIndexList |
A list of lists produced by |
aggregationType |
Character scalar. Use |
The function warns if lake names or IDs are not unique in the output.
A data.frame with lake identifiers (name, id) and one wide
year_<year> column per available year.
This function merges multiple annual lake index maps (each produced by
seasonal_index_per_lake()) into a unified per-pixel dataset. It ensures that
all years are represented on a common spatial grid. If differences in CRS
or grid alignment between years exist, the rasters are resampled to match
the most recent year's configuration.
combine_years_pixelData(lakeIndexList)combine_years_pixelData(lakeIndexList)
lakeIndexList |
A list of yearly lake index lists created by
|
The function performs the following steps:
Validates input to ensure lakeIndexList is a list of lists.
Extracts available years and their corresponding CRS values.
Selects the most recent year to define the target grid.
For each year, checks grid compatibility; if needed, resamples to the target resolution and CRS using bilinear interpolation.
Merges all years’ pixel tables into a single data frame by coordinates.
A list with the following elements:
yearsIndexA data.frame where each row corresponds to a pixel position
(x, y, i_row, i_col) and each yYYYY column stores the pixel values
of that year.
crsA character string giving the CRS of the final combined grid.
seasonal_index_per_lake(), terra::resample(), terra::rast()
Calculate adjusted linear trends over recent years
determine_trend(yearly_spread = yearly_spread, tyears = 3, ttype = "short")determine_trend(yearly_spread = yearly_spread, tyears = 3, ttype = "short")
yearly_spread |
A data frame of lakes or pixels as row and the yearly index values as columns |
tyears |
The number of years used for the trend analysis. |
ttype |
Character scalar, either |
In order to rule out systematic errors based on weather conditions in a year,
different hardware or algorithms, the difference between the overall median
value of all lakes (or all pixels) and years and the yearly median value of
all lakes(or all pixels) is added to the Index of a lake (or pixel) before
the trends are calculated. Median values are based on lakes or pixels for which data is available in all considered
years.
Subsequantly, the trend is calculated as linear regression between previous
years and adjusted NDTrI values.
For a reliable trend assessment the number of lakes needs to be large enough
(n>10).
Only rows with complete data in all year columns are used to estimate
the global and yearly medians for the bias correction. Individual row trends
are returned as NA if any value in the selected trend window is missing.
A list with trends, periodYear, overallMedian, and
yearlyMedians. trends contains the slope and the standard error of the
slope for each row.
Assigns each yearly index value to one of nClass classes. Break points are
computed separately for each year using the observed minimum and maximum as
outer bounds and equally spaced inner breaks between lower and upper quantiles.
discreteClassAssessment(yearly_spread, nClass = 10, proportionExtreme = 0.05)discreteClassAssessment(yearly_spread, nClass = 10, proportionExtreme = 0.05)
yearly_spread |
Data frame with one or more columns whose names start
with |
nClass |
Integer. Number of classes to create per year. Default is |
proportionExtreme |
Numeric between 0 and 1. Initial proportion used for
the lower and upper quantiles that define the inner range. Default is |
If the requested extreme proportion would create class sizes smaller
than one class share, it is reduced to 1 / nClass. #' Breaks are constructed using actual data min/max for outer bounds and creates
nClass - 2 equally spaced classes between the proportionExtreme quantiles
(1 - proportionExtreme and 0 + proportionExtreme).
A list with assessment, breaks, nClass, and
proportionExtreme. assessment is the input data frame with additional
<year>_class columns. breaks contains the class boundaries for each year.
Creates an interactive leaflet map for quickly checking the spatial extent that will be used for an openEO request.
display_geometry(geom, zoom = 15)display_geometry(geom, zoom = 15)
geom |
Either a named numeric bounding box vector in the order |
zoom |
Numeric scalar. Initial leaflet zoom level. Default is |
Polygon coordinates are expected as latitude-longitude pairs, matching common copy/paste formats from map tools. They are internally switched to longitude-latitude order for leaflet. Bounding Box as a named vector or c("north" = lat1, "east" = lon1, "south" = lat2, "west" = lon2) or a list of pairs list(c(lat1, lng2), c(lat2, lon2), c(lat3, lon3))
A leaflet map object with either a rectangle or polygon overlay.
Searches for a finished openEO job by title or ID and downloads its results to a local folder. The function assumes that the user is already connected and authenticated with openEO.
download_openEO_job( title, path, recentJob = TRUE, ID = NULL, overwrite = FALSE )download_openEO_job( title, path, recentJob = TRUE, ID = NULL, overwrite = FALSE )
title |
Character scalar. Job title to search for and folder name used
under |
path |
Character scalar. Directory into which the job folder is written. |
recentJob |
Logical. If |
ID |
Optional openEO job identifier or list index. If supplied, this is used instead of title matching. |
overwrite |
Logical. If |
Invisibly returns NULL. On success, job assets are written to
file.path(path, title). If the job is not finished, a message is printed
and no files are downloaded.
Converts image-wise remote-sensing index matrices into pixel-wise time series and calculates smoothed 365-day dynamics. The output includes lake-level summary statistics and, optionally, the individual pixel dynamics.
dynamic_per_pixel( imageIndex, nc, water_scenes_only = TRUE, days_around_ma = 20, maxPixels = 1000, pixelFilter = NULL, pixelQualityThreshold = 0.8, maxDataPoints = 5e+06, returnSinglePixels = TRUE )dynamic_per_pixel( imageIndex, nc, water_scenes_only = TRUE, days_around_ma = 20, maxPixels = 1000, pixelFilter = NULL, pixelQualityThreshold = 0.8, maxDataPoints = 5e+06, returnSinglePixels = TRUE )
imageIndex |
A list created by |
nc |
A netCDF list returned by |
water_scenes_only |
Logical. If |
days_around_ma |
Integer or |
maxPixels |
Numeric. Maximum number of pixels for which individual
dynamics are calculated. Values |
pixelFilter |
Optional integer vector of pixel positions in the original matrix order. If supplied, exactly these pixels are processed. |
pixelQualityThreshold |
Optional numeric scalar between 0 and 1. Minimum water-scene proportion required for a pixel. If "byMedian", the median number of valid observations among non-empty pixels is used to select pixels. |
maxDataPoints |
Numeric. Maximum number of matrix cells processed in one block. Larger datasets are split to reduce memory pressure. |
returnSinglePixels |
Logical. If |
For each day of year, all images within days_around_ma days before
and after the target day are averaged. A moving average is only calculated
if more than one image falls into the window. Long periods without image
availability are set to NA to avoid excessive temporal extrapolation.
A list with lakeDynamic, crs, year, days_around_ma, and
dataAvailabilityThreshold. If returnSinglePixels = TRUE, the list also
contains x, y, and pixelDynamics.
Orders lakes or rows from a numericAssessment() result according to the
selected trend column.
find_trends( numericAssessment, trendType, bestTrendFirst = FALSE, outputVector = "lakeID" )find_trends( numericAssessment, trendType, bestTrendFirst = FALSE, outputVector = "lakeID" )
numericAssessment |
A list created by |
trendType |
Character scalar, usually |
bestTrendFirst |
Logical. Passed to the ordering step. A good Trend is a negative trend, indicating a decrease in eutrophication. |
outputVector |
Character scalar. One of |
An ordered vector of lake IDs, lake names, or row numbers. Rows with missing trend values are removed from the ranking.
Create a matrix of clusters in the same dimension as Datacube nc
get_clusterLayer(clusterVector, nc)get_clusterLayer(clusterVector, nc)
clusterVector |
A named vector of clusters per pixel. The names are
are made of the index within the datacube xy-matrix combined the "p_" as
prefix (Vector is part of the returned output by |
nc |
A netCDF list returned by |
Extracts all time layers of a selected Sentinel-2 band from an open_netcdf()
object, optionally restricted to selected months and years.
load_BandLayer(nc, band, monthFilter = NULL, yearFilter = NULL)load_BandLayer(nc, band, monthFilter = NULL, yearFilter = NULL)
nc |
A list returned by |
band |
Character scalar with the band name to load, for example |
monthFilter |
Optional numeric vector of months to retain. |
yearFilter |
Optional numeric vector of years to retain. |
Negative band values are set to zero before matrices are returned. This is intended for reflectance bands and follows the Sentinel-2 pre-processing convention to harmonize data (https://docs.sentinel-hub.com/api/latest/data/sentinel-2-l2a/)
A list containing coordinates, time metadata, CRS, and band, a list
of matrices with one matrix per retained time step.
Reprojects a matrix aligned with an open_netcdf() object to WGS 84 and adds
it as a raster overlay on an interactive leaflet map.
map_layer( ncLayer, nc, lowerLimits = NULL, highestValue = NULL, classColors = NULL, valueRange = NULL, legendTitle = NULL, plotLegend = TRUE )map_layer( ncLayer, nc, lowerLimits = NULL, highestValue = NULL, classColors = NULL, valueRange = NULL, legendTitle = NULL, plotLegend = TRUE )
ncLayer |
Matrix with the same row and column dimensions as the netCDF grid. Values can be numeric classes, continuous numeric values, or hex color strings. |
nc |
A list returned by |
lowerLimits |
Optional numeric vector of lower class limits. If supplied,
categorical intervals are created with |
highestValue |
Optional numeric upper bound appended to |
classColors |
Character vector of colors corresponding to the classes
defined by |
valueRange |
Optional numeric vector of length two for continuous color scaling. |
legendTitle |
Optional character scalar used as legend title. |
plotLegend |
Logical. If |
The function supports a hex-color mode when all values of ncLayer
are character strings beginning with #.
A leaflet map object.
Calculates the proportion of pixels belonging to a selected Sentinel-2 SCL scene group for each image in a netCDF data cube.
nc_scene_per_image(nc, scene = "clouds")nc_scene_per_image(nc, scene = "clouds")
nc |
A list returned by |
scene |
Character scalar. One of |
Scene groups are mapped to SCL codes as follows: clouds = 8, 9, 10; water = 6; snow = 11; shadows = 2, 3.
A data.frame with columns date and coverage. coverage is the
proportion of pixels in the selected scene group for each image.
Loads two bands from a netCDF data cube and calculates an pixel-wise normalized difference index for each retained time step.
ndi_per_image(nc, year, bandNames = c("B05", "B02"), monthFilter = NULL)ndi_per_image(nc, year, bandNames = c("B05", "B02"), monthFilter = NULL)
nc |
A netCDF list created by |
year |
Numeric scalar. Year to process. Only one year can be processed at a time. |
bandNames |
Character vector of length two. The index is calculated as
|
monthFilter |
Optional numeric vector of months to include. If |
Band values are loaded through load_BandLayer(), which sets
negative values to zero before index calculation.
A list containing x, y, t, t_date, crs, and RSindex. The
RSindex element is a list of matrices, one per image.
Colors for the Index
NDTrIColorsNDTrIColors
A dataframe of two columns. "ndtri" listing the values of the noramlized diference trophic index and "color" specifying the corresponding colors
Adds moving-average status and relative short- and long-term trend estimates to a wide table of yearly index values.
numericAssessment( yearly_spread, statusYears = 3, shortTermYears = 3, longTermYears = 10 )numericAssessment( yearly_spread, statusYears = 3, shortTermYears = 3, longTermYears = 10 )
yearly_spread |
A data frame with lake or pixel identifiers and yearly
index columns named |
statusYears |
Integer. Number of years used for moving-average status.
Default is |
shortTermYears |
Integer. Number of years used for the short-term trend.
Default is |
longTermYears |
Integer. Number of years used for the long-term trend.
Default is |
In order to rule out systematic errors based on weather conditions in a year, different hardware or algorithms, the difference between the overall median value of all lakes (or pixels) and years and the yearly median value of all lakes (or pixels) is added to each index per year before the trends are calculated. Thus, the trends of one lake (or pixel) are relative compared to the other lakes (or pixels) of the table. The trend is calculated as linear regression between previous years and adjusted NDI values. For a reliable trend assessment the number of lakes (or pixels) needs to be large enough (n>10).
A list with assessment and periods. assessment is the input data
frame extended by status and trend columns where possible. periods records
the three period lengths used.
Combines a list of annual seasonal_index_per_lake() outputs for one lake
into a long-format summary table.
oneLake_df(lakeIndexList)oneLake_df(lakeIndexList)
lakeIndexList |
A list of yearly lake index lists, usually all belonging to the same lake. |
A data.frame with lake name, lake ID, year, median index, standard
deviation, selected modal index, number of valid pixels, and quality
threshold.
Reads a netCDF file into a terra SpatRaster and extracts spatial, temporal,
band, and CRS metadata used by the lakeRS processing workflow.
open_netcdf(filePath, fileName = "openEO.nc")open_netcdf(filePath, fileName = "openEO.nc")
filePath |
Character scalar. Directory containing the netCDF file. |
fileName |
Character scalar. File name including the |
The function stops if subdatasets in the netCDF file have different row, column, or layer dimensions.
A list with bands, x, y, t, t_date, crs, and SpRast.
x and y are pixel-center coordinates, t contains numeric time steps,
and t_date converts these time steps to dates using origin
1990-01-01.
Performs k-means clustering on pixel-level moving-average dynamics and returns cluster assignments, cluster centers, and selected k-means diagnostics.
pixel_clusters( pixelDynamic, k, iter.max = 20, nstart = 10, correlate_first = FALSE, whole_dynamic = FALSE )pixel_clusters( pixelDynamic, k, iter.max = 20, nstart = 10, correlate_first = FALSE, whole_dynamic = FALSE )
pixelDynamic |
A list or data-frame-like object of pixel dynamics,
usually |
k |
Integer. Number of clusters. |
iter.max |
Integer. Maximum number of k-means iterations. |
nstart |
Integer. Number of random starts passed to |
correlate_first |
Logical. If |
whole_dynamic |
Logical. If |
A list with clusterVector, clusterCenter, kmeansOut, and
days_included.
Draws a class-by-year heatmap for selected lakes from a
discreteClassAssessment() result.
plot_class_assessment( class_assessment, lakeNames = NULL, lakeIDs = NULL, rowNumbers = NULL )plot_class_assessment( class_assessment, lakeNames = NULL, lakeIDs = NULL, rowNumbers = NULL )
class_assessment |
A list created by |
lakeNames |
Optional character vector of lake names to plot. |
lakeIDs |
Optional character vector of lake IDs to plot. |
rowNumbers |
Optional numeric vector of row numbers in the assessment table to plot. |
At least one of lakeNames, lakeIDs, or rowNumbers must identify
rows. Colors are generated by rescale_classColors().
No explicit return value. The function draws a base R plot.
Draws one or more 365-day time series and optionally overlays 50% and 95%
interval polygons. The function is designed for lake-level or cluster-level
dynamics derived from dynamic_per_pixel() or combine_years_dynamic().
plot_dynamic( v_averageList, v_sdList = NULL, df_q50List = NULL, df_q95List = NULL, TScolors = lakeRS::tenClusterColors$color, TSnames = NULL, df_reference = NULL, RefName = NULL, lakeName = "", ylab = "Index", ylim = NULL )plot_dynamic( v_averageList, v_sdList = NULL, df_q50List = NULL, df_q95List = NULL, TScolors = lakeRS::tenClusterColors$color, TSnames = NULL, df_reference = NULL, RefName = NULL, lakeName = "", ylab = "Index", ylim = NULL )
v_averageList |
Numeric vector or list of numeric vectors with one value per day of year. |
v_sdList |
Optional numeric vector or list of vectors with standard deviations. If supplied, 50% and 95% intervals are approximated from the standard deviations. |
df_q50List |
Optional data frame or list of data frames with lower and upper 50% interval columns. |
df_q95List |
Optional data frame or list of data frames with lower and upper 95% interval columns. |
TScolors |
Character vector of colors for the time series and polygons. |
TSnames |
Optional character vector of legend names for the time series. |
df_reference |
Optional two-column data frame with reference day and value columns. |
RefName |
Optional character scalar for the reference-line legend. |
lakeName |
Character scalar used as plot title prefix. |
ylab |
Character scalar. Y-axis label. |
ylim |
Optional numeric vector of length two with y-axis limits. |
Month separators and labels are drawn for a non-leap 365-day year.
Missing interval values are removed with rm_na_for_polygon() before
polygons are drawn.
No explicit return value. The function draws a base R plot.
Draws a histogram and density curve of all valid pixel-level index values for a lake in one year. The selected modal value and median are highlighted.
plot_lake_index_histogram(lakeIndex, lakeName = "", indexName = "")plot_lake_index_histogram(lakeIndex, lakeName = "", indexName = "")
lakeIndex |
A list created by |
lakeName |
Character scalar used in the plot title. |
indexName |
Character scalar used as x-axis label. |
The current implementation reads lakeIndex$nValidePixel, matching
the current spelling in seasonal_index_per_lake().
NULL if no valid pixels are available; otherwise no explicit return
value. The function draws a base R plot.
Reprojects a matrix aligned with a netCDF grid to WGS 84 and plots it with a distance scale and optional legend using base graphics.
plot_layer( ncLayer, nc, lowerLimits = NULL, classColors = NULL, highestValue = NULL, valueRange = NULL, legendTitle = NULL, plotLegend = TRUE )plot_layer( ncLayer, nc, lowerLimits = NULL, classColors = NULL, highestValue = NULL, valueRange = NULL, legendTitle = NULL, plotLegend = TRUE )
ncLayer |
Matrix with the same row and column dimensions as the netCDF grid. Values can be numeric or hex color strings. |
nc |
A list returned by |
lowerLimits |
Optional numeric vector of class lower limits. |
classColors |
Character vector of colors for classes. In continuous mode
without |
highestValue |
Optional upper bound for the last class. |
valueRange |
Optional numeric vector of length two for continuous value scaling. |
legendTitle |
Optional character scalar used as legend title. |
plotLegend |
Logical. If |
The plot is scaled according to geodesic width and height estimated
with geosphere::distGeo(). The helper plot_scale() adjusts the plot
region to preserve the map's aspect ratio.
No explicit return value. The function draws a base R plot.
Creates a multi-panel base R plot showing one selected lake's yearly index values, moving-average status, and long- and short-term trend estimates.
plot_numeric_assessment( numericData, lakeName = NULL, lakeID = NULL, rowNumber = NULL, ylab = "Index" )plot_numeric_assessment( numericData, lakeName = NULL, lakeID = NULL, rowNumber = NULL, ylab = "Index" )
numericData |
A list created by |
lakeName |
Optional character scalar identifying the lake by name. |
lakeID |
Optional character scalar identifying the lake by ID. |
rowNumber |
Optional numeric row number in |
ylab |
Character scalar. Y-axis label for the index panel. |
Exactly one lake should be selected, either by row number, lake name, or lake ID. The first panel shows the distribution of all lakes as quantile bands and overlays the selected lake's annual values and status line. The two trend panels show point estimates with approximate 95% intervals.
No explicit return value. The function opens a graphics device and draws the assessment plot.
Visualizes image dates over the day of year, grouped by year, and colors each image according to a scene-coverage proportion.
plot_scene_coverage( vDate, vCoverage = NULL, upperLimits = c(0.05, 0.1, 0.3, 0.5, 0.75, 1) )plot_scene_coverage( vDate, vCoverage = NULL, upperLimits = c(0.05, 0.1, 0.3, 0.5, 0.75, 1) )
vDate |
Date vector of image acquisition dates. |
vCoverage |
Optional numeric vector or one-column data frame of scene
proportions per image, such as the |
upperLimits |
Numeric vector of upper interval limits between 0 and 1.
Default is |
Duplicate images on the same day of year are vertically offset within the year row. The right axis shows the number of images per year.
No explicit return value. The function draws a base R plot.
Cleans and optionally transforms a pixel-by-day moving-average matrix before k-means clustering.
prepare_for_clustering( moving_averages_matrix, correlate_first = FALSE, maxPixels = NULL )prepare_for_clustering( moving_averages_matrix, correlate_first = FALSE, maxPixels = NULL )
moving_averages_matrix |
Matrix or data frame with days as rows and pixels as columns. The first column is dropped before processing, matching outputs that include a day-of-year column. |
correlate_first |
Logical. If |
maxPixels |
Optional integer. Maximum number of pixels to retain. If not
|
Values are rounded with signif() before clustering. Depending on
the NA pattern, the function removes either rows with missing values or
pixels with missing values and reports removals via warnings. If correlation
pre-processing is requested, at most 1,000 reference pixels are sampled.
A numeric matrix used as input for clustering. Columns represent
pixels when correlate_first = FALSE; otherwise the matrix contains rounded
correlation profiles.
Reprojects a terra input raster to a specified target coordinate reference system (CRS), preserving the original number of rows and columns. The spatial extent of the raster is transformed to the new CRS, and a new raster template is created to match these dimensions before projection.
sameDimProjection(initial_raster, finalCRS = "EPSG:4326")sameDimProjection(initial_raster, finalCRS = "EPSG:4326")
initial_raster |
A |
finalCRS |
Character string specifying the target CRS, in |
The input extent is projected to the target CRS and used to create a
template raster. Projection uses nearest-neighbor resampling (method = "near"), which is appropriate for categorical layers and avoids creating
interpolated class values.
A SpatRaster object reprojected to the specified CRS, maintaining the same
number of rows and columns as the input raster.
terra::project(), terra::rast(), terra::ext()
Adds a mobile-friendly viewport meta tag to a leaflet widget and saves it as a self-contained HTML file.
save_leaflet(x, file)save_leaflet(x, file)
x |
A |
file |
Character scalar. Output HTML file including path. |
The return value of htmlwidgets::saveWidget(). The main side effect
is writing file.
Sentinel-2 IDs of the SCL Band
sceneIDssceneIDs
A data frame of two columsn 1) SCL ID and 2) SCL name
Summarizes the pixel-level seasonal index matrix of one lake and year into lake-level statistics, including median, standard deviation, density-based modal candidates, and a selected modal index value.
seasonal_index_per_lake(seasonIndex, lakeName = NULL, lakeID = NULL)seasonal_index_per_lake(seasonIndex, lakeName = NULL, lakeID = NULL)
seasonIndex |
A list created by |
lakeName |
Optional character scalar with the lake name. If |
lakeID |
Optional character scalar with a lake identifier. If |
If more than one valid pixel is available, potential modes are
detected from a kernel density estimate using bw = "SJ" and adjust = 2.
Among sufficiently high local maxima, the mode with the highest density is
selected as IndexModusBest. If exactly one valid pixel is available, that
value is used for both median and mode.
A list with index statistics (IndexModusBest, IndexMedian,
IndexSD, IndexModusPot, IndexDensity, IndexPixel), metadata
(QualityThreshold, x, y, crs, year), and lake identifiers (Name,
ID).
Filters image-wise index matrices by Sentinel-2 SCL information, averages the remaining index values pixel by pixel, and removes pixels that do not meet a water-scene quality threshold.
seasonal_index_per_pixel( imageIndex, nc, water_scenes_only = TRUE, pixelQualityThreshold = 0.8 )seasonal_index_per_pixel( imageIndex, nc, water_scenes_only = TRUE, pixelQualityThreshold = 0.8 )
imageIndex |
A list created by |
nc |
A netCDF list returned by |
water_scenes_only |
Logical. If |
pixelQualityThreshold |
Numeric between 0 and 1. Minimum water-scene proportion required for a pixel to be retained in the seasonal index. |
Water-scene proportions are calculated by waterscene_proportion().
A warning is issued if no pixel meets pixelQualityThreshold.
A list with x, y, crs, year, QualityThreshold, RSindex, and
sceneProportions. RSindex is a matrix of seasonal pixel index values;
pixels below the water-quality threshold are set to NA.
Projects input coordinates to WGS 84 and displays them as circle markers on a leaflet map.
show_pixels(x, y, crs, labels = NULL)show_pixels(x, y, crs, labels = NULL)
x |
Numeric vector of x coordinates (e.g., easting or longitude in the source coordinate reference system). |
y |
Numeric vector of y coordinates (e.g., northing or latitude in the
source coordinate reference system). Must be the same length as |
crs |
Character string specifying the source coordinate reference
system of |
labels |
Optional character vector of labels for the markers. If
provided, its length should match the length of |
The marker colors are currently hard-coded as c("blue", "green",
"orange", "purple"). If the number of points exceeds the number of colors,
colors will be recycled.
A leaflet map object.
Builds an openEO process graph for a Sentinel-2 collection, spatial and temporal extent, optional property filters, and selected bands. The graph is saved as the requested output format and started as an openEO batch job.
start_openEO_job( title, geom, tBeg, tEnd, crs = 4326, collection = "SENTINEL2_L2A", bands = list("B02", "B05", "SCL"), relativeOrbitNumber = NULL, tileID = NULL, outputFormat = "netCDF", uniqueTitle = TRUE )start_openEO_job( title, geom, tBeg, tEnd, crs = 4326, collection = "SENTINEL2_L2A", bands = list("B02", "B05", "SCL"), relativeOrbitNumber = NULL, tileID = NULL, outputFormat = "netCDF", uniqueTitle = TRUE )
title |
A character defining the job title (can be a lake name, id). It is advised to use a unique name (i.e. including a timestamp) that is used on openEO and as a folder on the local machine |
geom |
Numerical vector defining the bounding box in the coordinate reference system as defined in crs. The order of the values is north, east, south, west. Alternatively, geom can be a list of 3 or more latitude-longitude pairs, each pair is a vector of length 2 in the list to create a polyong (which is actually not bounding box any longer...) |
tBeg, tEnd
|
Dates in the format "YYYY-MM-DD" which define the temporal extent of the data to be downloaded. Left side (tBeg) is included, right side (tEnd) is excluded from range. |
crs |
A numerical value defining the coordinate reference system. By default this is 4326 (WGS 84). See here for further information: https://epsg.io/4326 |
collection |
One of the available collections on openEO
(SENTINEL2_L2A is default). The collections can be listed by
|
bands |
A list of characters defining The bands to be downloaded. For the normalized difference trophic index bands 2, 5 and the scene classification (SCL) are required. Set to NULL to download all bands. |
relativeOrbitNumber |
Definition of relativeOrbitNumber to filter for as character vector. |
tileID |
Definition of Tiles to filter for as character vector. |
outputFormat |
On of the available output formats (netcdf is default).
The formats can be listed by |
uniqueTitle |
If TRUE, the previous jobs are checked. If the title has already been used, it is suffixed by an underscore and the lowest possible number |
Laitude-Longitude Pairs are switched to longitude-latitude which is the required order of openEO, however providing the data as latitude-longitude is more convient beacuse it is the google maps output format
This function only returns the title of the job that is started on openEO. To download the job use function download_openEO_job
Colors for the Classes
tenClassColorstenClassColors
A data frame of two columns. "class" listing the classes 1 to 10 and "color" specifying the corresponding colors
Colors for the Clusters
tenClusterColorstenClusterColors
A data frame of two columns. "cluster" listing the clusters 1 to 10 and "color" specifying the corresponding colors
Adds categorical trend-significance and trend-strength columns to an assessment table containing trend estimates and standard errors.
trends_to_classes(assessmentTable, trendType = "long")trends_to_classes(assessmentTable, trendType = "long")
assessmentTable |
A data frame, typically |
trendType |
Character scalar. Either |
Significance classes are 0 if zero lies within ±1 standard error,
±1 if zero lies outside ±1 but inside ±2 standard errors, and ±2 if zero
lies outside ±2 standard errors. Positive trend estimates are converted to
negative classes, so class sign follows the package's interpretation that a
negative numerical trend indicates improvement of the trophic index.
The input data frame extended by trend_<trendType>_significance and
trend_<trendType>_strength.
Computes per-pixel proportions for all Sentinel-2 SCL classes and derives a water-scene proportion after accounting for disturbance classes.
waterscene_proportion(scl_image)waterscene_proportion(scl_image)
scl_image |
A list of SCL matrices, typically loaded from the SCL band of
an |
The water proportion is defined as all pixels that are "correctly" classified as water. Thus, disturbances that occur but are not a false classification like clouds, snow or topographic impacts need to be removed before. After removing those pixels, the water classifiation should be 100% for a perfect pixel
A list with water, NoFalseDisturbance, and allScenes. water is
the derived water-scene proportion per pixel; NoFalseDisturbance is the
proportion of pixels assigned to allowed disturbance classes; allScenes is
a list of per-class proportions.