diff --git a/scripts/fetch/precip_grid_data.R b/scripts/fetch/precip_grid_data.R index a2ac3ac..e82fb68 100644 --- a/scripts/fetch/precip_grid_data.R +++ b/scripts/fetch/precip_grid_data.R @@ -8,5 +8,16 @@ fetch.precip_grid_data <- function(viz){ sp_grid_WGS84 <- sp::spTransform(sp_grid, "+proj=longlat +datum=WGS84") stencil <- geoknife::simplegeom(sp_grid_WGS84) - warning('the rest is not implemented') + fabric_args <- viz[["webdata_args"]] + + fabric <- geoknife::webdata( + url = fabric_args$url, + times = as.POSIXct(fabric_args$times), + variables = fabric_args$variables + ) + + job <- geoknife::geoknife(stencil, fabric, wait = TRUE, REQUIRE_FULL_COVERAGE=FALSE) + + data <- geoknife::result(job, with.units = TRUE) + saveRDS(data, file = viz[['location']]) } \ No newline at end of file diff --git a/scripts/process/grid_from_mask.R b/scripts/process/grid_from_mask.R index 390a503..3809ba3 100644 --- a/scripts/process/grid_from_mask.R +++ b/scripts/process/grid_from_mask.R @@ -23,6 +23,6 @@ process.grid_from_mask <- function(viz){ cell_grid_clipped <- sf::st_intersection(cell_grid, clip_mask) # add an id to be used for adding data later: - cell_grid_clipped <- st_sf(cell_grid_clipped, id = paste('cell_', 1:length(cell_grid_clipped), sep= '')) + cell_grid_clipped <- st_sf(cell_grid_clipped, row.names = paste('cell_', 1:length(cell_grid_clipped), sep= '')) saveRDS(cell_grid_clipped, file = viz[['location']]) } \ No newline at end of file diff --git a/viz.yaml b/viz.yaml index 6575269..6ebb549 100644 --- a/viz.yaml +++ b/viz.yaml @@ -37,6 +37,9 @@ info: sp: repo: CRAN version: 1.2.5 + geoknife: + repo: GRAN + version: 1.6.0 parameter: - id: spatial_metadata @@ -72,6 +75,11 @@ fetch: reader: rds fetcher: precip_grid_data scripts: scripts/fetch/precip_grid_data.R + webdata_args: + times: ["2014-01-01", "2014-01-04"] + url: "https://cida.usgs.gov/thredds/dodsC/stageiv_combined" + variables: "Total_precipitation_surface_1_Hour_Accumulation" + comment: "times and other metadata will be moved to another target, e.g., timesteps" depends: grid: precip_grid