| Title: | Lake Indicators from CrowdWater Observations |
|---|---|
| Description: | This package uses observations data of lakes collected by the CrowdWater App to derive semi-quantitative indictors for nutrients (trophic sate), biotop value, use of the lakes and water availability characteristics. |
| 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.0.0.9000 |
| Built: | 2026-06-14 19:39:49 UTC |
| Source: | https://github.com/KWB-R/kwb.CrowdWater |
Add all the indicators to the lake properties table
add_ObservationIndicators(df_cw)add_ObservationIndicators(df_cw)
df_cw |
Dataframe of the CrowdWater lake properties, prepared by
|
df_cw extended by 4 indicator columns
Used within the indicator functions
assign_points_MC(df, property, categories, points, NA_answers = "No answer")assign_points_MC(df, property, categories, points, NA_answers = "No answer")
df |
Prepared CrowdWater data frame |
property |
Character Value. One of the column names of df |
categories |
Character vector that lists the catetories of the property for which points are assigned |
points |
Numeric vector of the same length and order of the categories vector with the assigned points |
NA_answers |
Character vector defining one or more answers that are treated as NA values |
a list of
points: Numeric vector of the category points
valid_answer: Logical vector if all the required properties were observed
scoring_system: The points assigned to the categories
Used within the indicator functions
assign_points_SC(df, property, categories, points, NA_answers = "No answer")assign_points_SC(df, property, categories, points, NA_answers = "No answer")
df |
Prepared CrowdWater data frame |
property |
Character Value. One of the column names of df |
categories |
Character vector that lists the catetories of the property for which points are assigned |
points |
Numeric vector of the same length and order of the categories vector with the assigned points |
NA_answers |
Character vector defining one or more answers that are treated as NA values |
a list of
points: Numeric vector of the category points
valid_answer: Logical vector if all the required properties were observed
scoring_system: The points assigned to the categories
the Basemap used for all leaflet maps
base_map( longitude = 13.3987, latitude = 52.5048, zoom = 11, berlin_districts = TRUE )base_map( longitude = 13.3987, latitude = 52.5048, zoom = 11, berlin_districts = TRUE )
longitude |
Numeric value defining the longitude if WGS84 |
latitude |
Numeric value defining the latitude if WGS84 |
zoom |
The initial and minimum zoom level |
berlin_districts |
Logical value if berlin districts should be added |
A leaflet map
Regions Bounding Boxes
bboxesbboxes
A named list of regions defined by bounding boxes. The bounding boxes are numeric vectors of coordinates which define the top, bottom, left, and right coordinates of the box.(in WGS84)
Simple feature of the Berlin district boundaries
berlin_district_shpberlin_district_shp
Besides the geometry, the Name of the district and its ID is given
This function returns the sum of categories per property of the given dataframe
categories_sum(df, property, language = "english", includeNA = FALSE)categories_sum(df, property, language = "english", includeNA = FALSE)
df |
Dataframe of the crowdwater lake properties prepared by
|
property |
The property |
language |
A character string, defining the language of df. If unknown
the function |
includeNA |
Logical if NA (No answer) data should be included |
A dataframe with the columns ROOT_ID, LATITUED, LONGITUDE and all the available categories per defined property. Besides the percentage of categories per site, the number of observations is given.
Adds additional information to legend values
create_legend_labels( lv, low_label = NULL, high_label = NULL, increase_bounds = TRUE )create_legend_labels( lv, low_label = NULL, high_label = NULL, increase_bounds = TRUE )
lv |
legend values as returned by |
low_label |
Additional lable for the lowest value |
high_label |
Additional lable for the highest value |
increase_bounds |
Add greater or equal / less or equal than sign to the highest /lowest legend value |
extended legend labels
Calculate all indicators for all recorded lakes
get_LakeIndicators(df_cw)get_LakeIndicators(df_cw)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
A dataframe that contains columns of the root id, coordinates, the indicator values and number of observations as well as the date of the most recent observation
Function identifies the language based on category names
identify_language(df_cw)identify_language(df_cw)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
A character string of the language
The indicator is calculated per observation
indicator_biotope(df_cw, return_scoring_system = FALSE)indicator_biotope(df_cw, return_scoring_system = FALSE)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
return_scoring_system |
If TRUE the scoring system is returned instead of the indicator vector. |
Either a numeric vector of the indicator points, or a description of the scoring system. This is a list of properties and categories which contribute to the indicator.
The indicator is calculated per observation
indicator_nutrients(df_cw, return_scoring_system = FALSE)indicator_nutrients(df_cw, return_scoring_system = FALSE)
df_cw |
Dataframe of the prepared crowdwater data |
return_scoring_system |
If TRUE the scoring system is returned instead of the indicator vector. |
Either a numeric vector of the indicator points, or a description of the scoring system. This is a list of properties and categories which contribute to the indicator.
The indicator is calculated per observation
indicator_usage(df_cw, return_scoring_system = FALSE)indicator_usage(df_cw, return_scoring_system = FALSE)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
return_scoring_system |
If TRUE the scoring system is returned instead of the indicator vector. |
Either a numeric vector of the indicator points, or a description of the scoring system. This is a list of properties and categories which contribute to the indicator.
The indicator is calculated per observation
indicator_waterStress(df_cw, return_scoring_system = FALSE)indicator_waterStress(df_cw, return_scoring_system = FALSE)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
return_scoring_system |
If TRUE the scoring system is returned instead of the indicator vector. |
While most citizens are not able to tell if the lake experiences water stress by the observation at one point of time, there might be citizens who know the water body for a long time. The more observations include this information the more certain it is. Some citizen may only know about water level changes but cannot answer if the lake dries out. This is why in contrast to the other indicators, the points are counted even if one question remains unknown or unanswered.
Either a numeric vector of the indicator points, or a description of the scoring system. This is a list of properties and categories which contribute to the indicator.
Transformation of numeric values into colors
indicators_to_colors( v_indicator, v_worst, v_neutral, v_best, col_worst = "#E6550D", col_neutral = "#EFF3FB", col_best = "#08306B", col_NA = "#00000000", resolution_bad = 0.1, resolution_good = 0.1, resolution_legend = 1 )indicators_to_colors( v_indicator, v_worst, v_neutral, v_best, col_worst = "#E6550D", col_neutral = "#EFF3FB", col_best = "#08306B", col_NA = "#00000000", resolution_bad = 0.1, resolution_good = 0.1, resolution_legend = 1 )
v_indicator |
Numeric Vector of indicator data |
v_worst |
Worst possible value |
v_neutral |
Neutral value |
v_best |
Best possible value |
col_worst |
Color for worst value as hexadecimal string of the form "#rrggbb" |
col_neutral |
Color for worst value as hexadecimal string of the form "#rrggbb" |
col_best |
Color for worst value as hexadecimal string of the form "#rrggbb" |
col_NA |
Color for NA values (Transparent by default) |
resolution_bad |
the resolution between neutral and worst value |
resolution_good |
The resolution between netral and best value |
resolution_legend |
The resolution of the legend values |
Vector of colors corresponding to the indicator values
From single observation to average site indicators
lake_indicator(df_cw, indicator_type)lake_indicator(df_cw, indicator_type)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
indicator_type |
A character defining the indicator. Either "nutrients" "biotope", "usage" or "waterstress" |
A data frame of 5 columns (ROOT_ID, LATITUDE, LONGITUDE and the indicator value and the number of observations)
Returnes only the latest observations per lake
latest_observations(df_cw)latest_observations(df_cw)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
A dataframe in the same shape as the lake properties dataframe with all historical observations removed
The leaflet map has two layers. 1) all the observered properties 2) the corresponding image of that observation
leaflet_indicator(cw_indicators, language = "german")leaflet_indicator(cw_indicators, language = "german")
cw_indicators |
Dataframe of the crowdwater indicators per lake created
by |
language |
A character string, defining the language if the map |
A leflet map
Create an interactive leaflet map which contains the days passed since the last observations
leaflet_last_observation_days(df_cw, language = "german")leaflet_last_observation_days(df_cw, language = "german")
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
language |
A character string, defining the language if the map |
A leaflet map
The leaflet map has two layers. 1) all the observered properties 2) the corresponding image of that observation
leaflet_last_observation_info(df_cw, language = "german")leaflet_last_observation_info(df_cw, language = "german")
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
language |
A character string, defining the language if the map |
A leflet map
Merge two lake indicator tables
merge_LakeIndicators(x, y)merge_LakeIndicators(x, y)
x |
indicator table created by |
y |
indicator table created by |
merged table
The downloaded csv file is filtered for lake specific columns, for regions and for validated observations. The observed properties are named correctly in English.
prepare_data(path, file, region = NULL, validated_only = TRUE)prepare_data(path, file, region = NULL, validated_only = TRUE)
path |
The filepath |
file |
The filename including the ".csv" ending |
region |
Either a character defining a region which is available in or a numeric vector of coordinates in WGS84 shaping a rectangle by "top", "bottom", "left" and "right" coordinate. |
validated_only |
Logical if only checked observations are selected |
A list of two data frames. The first one contains data on the observered proberties, the second data frame contains data of the phyiscale category.
List of CrowdWater Properties and Categories
props_and_catsprops_and_cats
A named list where list names correspond to the crowdwater properties (column names of the table). For each property a data frame of categories is given, which includes the translation into German or English, the order of categories if applicable (if not -> NA) and the type of answers
Multiple choice answers per observation are combined a one cell of the table and seperated by a comma.
renameMultipleChoice(v, oldNames, newNames, sep = ", ")renameMultipleChoice(v, oldNames, newNames, sep = ", ")
v |
Character vector of categories |
oldNames |
Character vector listing the old names of the categories |
newNames |
Characteri vector listing the new names of the categories in the same order as the oldNames vector |
sep |
The seperator that is used in a cell between categories of the same observation |
Character vector of renamed categories
Replaces multiple category names by new names
renameSingleChoice(v, oldNames, newNames)renameSingleChoice(v, oldNames, newNames)
v |
Character vector of categories |
oldNames |
Character vector listing the old names of the categories |
newNames |
Characteri vector listing the new names of the categories in the same order as the oldNames vector |
Character vector of renamed categories
By adding content to the html it is assured that icons are scaled according to the device. In this way the map can be used by mobile devices.
save_leaflet(x, file)save_leaflet(x, file)
x |
Leaflet object to be saved |
file |
Filename including path |
Returnes only the latest observations per lake
site_category_percentage(df_cw, includeNA = FALSE)site_category_percentage(df_cw, includeNA = FALSE)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
includeNA |
Logical if NA (No answer) data should be included |
A dataframe in the same shape as the lake properties dataframe with all historical observations removed
From single observation to average site indicators
tranlsate_categories(df_cw, from, to)tranlsate_categories(df_cw, from, to)
df_cw |
Dataframe of the crowdwater lake properties prepared by
|
from |
Character string, defining the language of df_cw |
to |
Character string, defining the language to translate in |
df_cw translated