{"id":13299444,"url":"https://github.com/dimfalk/kostra2010R","last_synced_at":"2025-03-10T11:31:47.152Z","repository":{"id":44053465,"uuid":"473265408","full_name":"dimfalk/kostra2010R","owner":"dimfalk","description":"R interface for KOSTRA-DWD-2010R dataset","archived":false,"fork":false,"pushed_at":"2024-12-19T17:33:27.000Z","size":8475,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-19T18:33:54.868Z","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-03-23T16:14:01.000Z","updated_at":"2024-12-19T17:33:32.000Z","dependencies_parsed_at":"2024-04-03T09:47:08.922Z","dependency_job_id":"48fb9802-927f-4523-b67f-f92856f95093","html_url":"https://github.com/dimfalk/kostra2010R","commit_stats":{"total_commits":187,"total_committers":3,"mean_commits":"62.333333333333336","dds":"0.13903743315508021","last_synced_commit":"352c44de9d3dc2038eded98d8b51e150b23413df"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2010R","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2010R/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2010R/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimfalk%2Fkostra2010R/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimfalk","download_url":"https://codeload.github.com/dimfalk/kostra2010R/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242842916,"owners_count":20194291,"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.815Z","updated_at":"2025-03-10T11:31:47.145Z","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# kostra2010R\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/dimfalk/kostra2010R/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dimfalk/kostra2010R/actions/workflows/R-CMD-check.yaml) \n[![Codecov](https://codecov.io/gh/dimfalk/kostra2010R/graph/badge.svg)](https://app.codecov.io/gh/dimfalk/kostra2010R)\n\u003c!-- badges: end --\u003e\n\n--- As of 01.01.2023, kostra2010R is officially replaced by [kostra2020](https://github.com/dimfalk/kostra2020). ---\n\nThe main goal of kostra2010R is to provide access to KOSTRA-DWD-2010R 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_2010R/gis/DESCRIPTION_gridsgermany_return_periods_precipitation_KOSTRA_KOSTRA_DWD_2010R_gis_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) for 18 duration levels D (5 min - 3 days) and 9 return periods Tn (1-100 a) for the whole grid spanning 79 × 107 cells. INDEX_RC describes the unique identifier of a grid cell.\n\n## Installation\n\nYou can install the development version of kostra2010R with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"dimfalk/kostra2010R\")\n```\n\nand load the package via\n\n```{r}\nlibrary(kostra2010R)\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 11). 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 = 42, col = 16)\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(\"42016\")\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.09, 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, postal codes or full addresses to be geocoded via Nominatim API.\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-2010R 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(\"42016\")\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, 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 statistical uncertainties, as proposed in Malitz \u0026 Ertel (2015), ranging between 10 % and 20 % as a function of the chosen return period, 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\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(62.1, d = 240)\n\nas_depth(43.1, 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 75.2 mm in 24 h.\nget_returnp(stats, hn = 75.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-2010R.\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 = 38.2, 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 = 26.4, 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 = 92.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 = 75.2, d = 1440, interpolate = TRUE)\n```\n\n### Further utilization\n\nData can 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/kostra2010R/blob/main/.github/CONTRIBUTING.md) if you'd like to contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimfalk%2Fkostra2010R","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimfalk%2Fkostra2010R","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimfalk%2Fkostra2010R/lists"}