{"id":13299446,"url":"https://github.com/dimfalk/kostra2020","last_synced_at":"2025-03-10T11:31:47.811Z","repository":{"id":172832392,"uuid":"578631182","full_name":"dimfalk/kostra2020","owner":"dimfalk","description":"R interface for KOSTRA-DWD-2020 dataset","archived":false,"fork":false,"pushed_at":"2024-12-19T17:39:21.000Z","size":11105,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-19T18:34:51.716Z","etag":null,"topics":["dwd","kostra","precipitation","rainfall"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimfalk.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-15T14:10:24.000Z","updated_at":"2024-12-19T17:39:25.000Z","dependencies_parsed_at":"2024-08-01T12:59:57.449Z","dependency_job_id":"d39f4e6e-e93a-4841-924d-67d9e4dacf05","html_url":"https://github.com/dimfalk/kostra2020","commit_stats":{"total_commits":177,"total_committers":3,"mean_commits":59.0,"dds":"0.14689265536723162","last_synced_commit":"3ef62ba1cd74820c80fbe8f1fbe180dc9044832d"},"previous_names":["dimfalk/kostra2020"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2020","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2020/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2020/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2020/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimfalk","download_url":"https://codeload.github.com/dimfalk/kostra2020/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242842927,"owners_count":20194294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dwd","kostra","precipitation","rainfall"],"created_at":"2024-07-29T17:37:27.831Z","updated_at":"2025-03-10T11:31:47.794Z","avatar_url":"https://github.com/dimfalk.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# kostra2020\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/dimfalk/kostra2020/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dimfalk/kostra2020/actions/workflows/R-CMD-check.yaml) \n[![Codecov](https://codecov.io/gh/dimfalk/kostra2020/graph/badge.svg)](https://app.codecov.io/gh/dimfalk/kostra2020)\n\u003c!-- badges: end --\u003e\n\n--- As of 01.01.2023, kostra2020 officially replaces [kostra2010R](https://github.com/dimfalk/kostra2010R). ---\n\nThe main goal of kostra2020 is to provide access to KOSTRA-DWD-2020 dataset from within R.\n\nAbstract (slightly modified) from the [official dataset description](https://opendata.dwd.de/climate_environment/CDC/grids_germany/return_periods/precipitation/KOSTRA/KOSTRA_DWD_2020/Datensatzbeschreibung_KOSTRA-DWD-2020_en.pdf):\n\n\u003e This vector dataset contains statistical precipitation values as a function of duration and return period. The scope of the data is the engineering dimensioning of water management structures. These include, sewerage networks, sewage treatment plants, pumping stations and retention basins. They are also often used for the dimensioning of drainage  and infiltration systems. With the help of the data, however, it is also possible to estimate the precipitation level of severe heavy precipitation events with regard to their return periods. This estimation is often used to assess damage events.\n\n\u003e The dataset encompasses values of statistical precipitation (HN) and uncertainty range (UC) for 22 duration levels D (5 min - 7 days) and 9 return periods Tn (1-100 a). Here, the dataset has been filtered for grid cells with actual information available, reducing the full grid of 300 x 300 cells at a spatial resolution of 5 km to a relevant subset of 15,989 cells. Also, explicit rain donation (RN) information was removed since this data can be reproduced on the fly. INDEX_RC describes the unique identifier of a grid cell.\n\nFurther information can be found in the support documents at https://www.dwd.de/kostra\n\n## Installation\n\nYou can install the development version of kostra2020 with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"dimfalk/kostra2020\")\n```\n\nand load the package via\n\n```{r}\nlibrary(kostra2020)\n```\n\n## Getting started\n\n### Get \"INDEX_RC\" based on row and column information\n\nSometimes identification of grid cells is not accomplished using \"INDEX_RC\" directly but rather using a combination of X and Y information (e.g. row 49, column 125). This information can easily be used to generate the necessary \"INDEX_RC\" field.\n\n```{r}\n# Generate \"INDEX_RC\" based on row and column information.\nidx_build(row = 117, col = 111)\n```\n\nIf you wanted to check whether this constructed \"INDEX_RC\" field is really present in the dataset (or you found an ID in some report and are not sure, if it is still being used), make use of the following function.\n\n```{r}\n# Is the following \"INDEX_RC\" entry present in the dataset?\nidx_exists(\"117111\")\n```\n\n### Get \"INDEX_RC\" based on spatial information\n\nThe most common use case will be to get the relevant \"INDEX_RC\" based on coordinates provided, e.g. for the location of a precipitation station in order to be able to classify duration-specific precipitation depths in terms of return periods.\n\n```{r}\n# Sf objects created based on specified coordinates. Don't forget to pass the CRS.\np1 \u003c- get_centroid(c(6.19, 50.46), crs = \"epsg:4326\")\np1\n\np2 \u003c- get_centroid(c(367773, 5703579), crs = \"epsg:25832\")\np2\n```\n\nFor convenience, it is also possible to provide municipality names or postal codes to derive coordinates.\n\n```{r}\n# Sf objects created based on Nominatim API response. Internet access required!\np3 \u003c- get_centroid(\"40477\")\np3\n\np4 \u003c- get_centroid(\"Freiburg im Breisgau\")\np4\n\np5 \u003c- get_centroid(\"Kronprinzenstr. 24, 45128 Essen\")\np5\n```\n\nThese coordinates can be used subsequently to spatially query the relevant grid index.\n\n```{r}\n# Get indices by topological intersection between location point and grid cells.\nget_idx(p1)\nget_idx(p2)\nget_idx(p3)\nget_idx(p4)\nget_idx(p5)\n```\n\n### Construct cell-specific statistics from KOSTRA-DWD-2020 grid\n\nNow that we have messed a little with the grid cell identifiers, let's get a sneak peek into the dataset itself based on the \"INDEX_RC\" specified.\n\n```{r}\n# Build a tibble containing statistical precipitation depths as a function of \n# duration and return periods for the grid cell specified.\nstats \u003c- get_stats(\"117111\")\n\nstats\n```\n\nSome describing attributes have been assigned to the tibble.\n\n```{r}\nattr(stats, \"id\")\nattr(stats, \"period\")\nattr(stats, \"returnperiods_a\")\nattr(stats, \"source\")\n```\n\n### Get precipitation depths and uncertainties, calculate precipitation yield\n\nIf we now wanted to know the statistical precipitation depth e.g. for an event of 4 hours duration corresponding to a recurrence interval in 1:100 years, it's just a matter of indexing. However, there is a function helping you out.\n\n```{r}\n# So we are interested in the rainfall amount [mm] for an event lasting 240 min \n# with a return period of 100 a.\nget_depth(stats, d = 240, tn = 100)\n```\n\nIn order to respect estimated grid cell specific uncertainties now additionally included in kostra2020, make use of `uc = TRUE` to get an interval centered around the single value above.\n\n```{r}\n# Same data, but with uncertainties considered.\nget_depth(stats, d = 240, tn = 100, uc = TRUE)\n```\n\nUncertainties are caused on the one hand by the statistical procedures themselves, but on the other hand also by the regionalisation procedure and by erroneous or missing observations. The uncertainties vary regionally and depend on the duration level and return period. For example, the rarer an event occurs statistically, the greater the uncertainties.\n\nSpecific uncertainty data is available for each grid cell and for each combination of duration level D and return period Tn. Please note that uncertainty ranges are given in ± %.\n\n```{r}\n# Inspect raw uncertainties used above.\nget_uncertainties(\"117111\")\n```\n\nIf you need precipitation yield values [l/(s\\*ha)] instead of precipitation depth [mm] or vice versa, make use of the following helper function.\n\n```{r}\nas_yield(55.6, d = 240)\n\nas_depth(38.6, d = 240)\n```\n\n### Get return periods\n\nFinally, we want to determine the return period according to the dataset for a precipitation depth and duration given.\n\n```{r}\n# Let's assume we measured 86.2 mm in 24 h.\nget_returnp(stats, hn = 86.2, d = 1440)\n```\n\nAccordingly, the approximate corresponding recurrence interval resp. annuality of this event amounts to something between 30 and 50 years as per KOSTRA-DWD-2020.\n\nThe following edge cases are to be mentioned:\n\n```{r}\n# 1) In case a class boundary is hit, the return period is replicated.\nget_returnp(stats, hn = 41.8, d = 1440)\n```\n\n```{r}\n# 2) In case the return period tn is smaller than 1, interval opens with 0.\nget_returnp(stats, hn = 32.1, d = 1440)\n```\n\n```{r}\n# 3) In case the return period tn is larger than 100, interval closes with Inf.\nget_returnp(stats, hn = 110.8, d = 1440)\n```\n\n### Return period interpolation\n\nAlthough it may be somewhat questionable from a scientific perspective, you might nevertheless be interested in the return period estimated using linear interpolation between adjacent nodes:\n\n```{r}\n# Using the same example as above, previously resulting in 30 a \u003c tn \u003c 50 a.\nget_returnp(stats, hn = 86.2, d = 1440, interpolate = TRUE)\n```\n\n### Further utilization\n\nData can now additionally be visualized as intensity-duration-frequency curves using `plot_idf()`, underpinned by `{ggplot2}` ...\n\n```{r, fig.width = 9}\nplot_idf(stats, log10 = TRUE)\n```\n\n... or exported to disk using `write_stats()` based on `write.table()`.\n\n## Contributing\n\nSee [here](https://github.com/dimfalk/kostra2020/blob/main/.github/CONTRIBUTING.md) if you'd like to contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimfalk%2Fkostra2020","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimfalk%2Fkostra2020","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimfalk%2Fkostra2020/lists"}