Skip to content

Commit

Permalink
Merge pull request #52 from KWB-R/read-data-over-shape
Browse files Browse the repository at this point in the history
Read data over shape
  • Loading branch information
mrustl authored Apr 8, 2024
2 parents b7b5787 + 0ee1aed commit 3c95839
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 243 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export(radolan_raw_to_raster)
export(read_asc_gz_file)
export(read_binary_radolan_file)
export(read_daily_data_over_shape)
export(read_data_over_shape)
export(read_monthly_data_over_shape)
export(read_relevant_years_radolan)
export(temp_dir)
Expand Down
17 changes: 17 additions & 0 deletions R/download_grids_germany.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
download_grids_germany <- function(resolution, variable, from, to, quiet = FALSE)
{
if (resolution == "daily") {

# Download and extract .tgz files from DWD server
download_daily_grids_germany(variable, from, to, quiet = quiet)

} else if (resolution == "monthly") {

# Download files from DWD server
download_monthly_grids_germany(variable, from, to, quiet = quiet)

} else {

clean_stop("resolution must be one of 'daily', 'monthly'.")
}
}
3 changes: 3 additions & 0 deletions R/get_radolan_projection_string.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#' * [get_radolan_extension].
get_radolan_projection_string <- function()
{
# TODO: Is this the same?
# readLines(default_projection_file())

to_projection_string(
parameters = list(
proj = "stere",
Expand Down
9 changes: 3 additions & 6 deletions R/read_asc_gz_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,22 @@ read_asc_gz_file <- function(file, url = NULL)

#dir(target_dir)

# Provide a copy of the projection file in the download folder
provide_projection_file(grid_file)

raster::raster(grid_file)
# Read the .asc file into a raster object (with appropriate projection)
read_asc_file(grid_file)
}

# read_asc_file ----------------------------------------------------------------

#' Read Raster Data from .ASC File
#'
#' @param file path to .asc file
#' @param projection projection string used in Radolan data
#' @param projection projection string used in Radolan data. Currently not used!
#' @param dbg logical indicating whether to show debug messages
#' @importFrom kwb.utils catAndRun
#' @importFrom raster `crs<-` raster
read_asc_file <- function(
file,
projection = get_radolan_projection_string(),
#projection = readLines(default_projection_file()),
dbg = TRUE
)
{
Expand Down
131 changes: 0 additions & 131 deletions R/read_daily_data_over_shape.R

This file was deleted.

Loading

0 comments on commit 3c95839

Please sign in to comment.