Skip to content

Commit

Permalink
interpolate arrays
Browse files Browse the repository at this point in the history
interpolate arrays
  • Loading branch information
PondiB authored May 16, 2024
2 parents f070727 + 1e531fb commit eac9afd
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
11 changes: 11 additions & 0 deletions R/Collection-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#' @field id Id of the collection
#' @field title Collection title
#' @field description Short description of the collection
#' @field spatialExtent Spatial extent of the collection
#' @field temporalExtent Temporal extent of the collection
#' @field bands Bands of the collection
#' @field constellation Constellation of the collection
#'
#' @include Session-Class.R
#' @importFrom R6 R6Class
Expand All @@ -27,6 +31,7 @@ Collection <- R6Class(
#' @param spatialExtent Spatial extent of the collection
#' @param temporalExtent Temporal extent of the collection
#' @param bands Bands of the collection
#' @param constellation Constellation of the collection
#'
initialize = function(id = NA, title = NA, description = NA, spatialExtent = NA, temporalExtent = NA, bands = NA, constellation = NA) {
self$id = id
Expand All @@ -38,6 +43,9 @@ Collection <- R6Class(
self$constellation = constellation
},

#' @description Get collection information
#'
#' @return A list containing collection information
collectionInfo = function() {
list(
stac_version = Session$getConfig()$stac_version,
Expand Down Expand Up @@ -66,6 +74,9 @@ Collection <- R6Class(
)
},

#' @description Get extended collection information
#'
#' @return A list containing extended collection information
collectionInfoExtended = function() {
list(
stac_version = Session$getConfig()$stac_version,
Expand Down
2 changes: 2 additions & 0 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ addEndpoint = function() {
Session$assignProcess(save_result)
Session$assignProcess(aggregate_temporal_period)
Session$assignProcess(array_element)
Session$assignProcess(array_interpolate_linear)
Session$assignProcess(filter_bands)
Session$assignProcess(filter_bbox)
Session$assignProcess(filter_spatial)
Expand All @@ -316,4 +317,5 @@ addEndpoint = function() {
Session$assignProcess(divide)
Session$assignProcess(evi)


}
37 changes: 37 additions & 0 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,43 @@ load_stac <- Process$new(
}
)

#' array interpolate linear
array_interpolate_linear <- Process$new(
id = "array_interpolate_linear",
description = "Performs a linear interpolation for each of the no-data values (null) in the array given, except for leading and trailing no-data values.",
categories = as.array("arrays", "reducer"),
summary = "Get an element from an array",
parameters = list(
Parameter$new(
name = "data",
description = "An array",
schema = list(type = "array")
)
),
returns = list(
description = "The value of the requested element.",
schema = list(description = "Any data type is allowed.")
),
operation = function(data, job) {
method <- "linear"
tryCatch({
message("\nFill NA values...")

gdalcubes::fill_time(data, method)

message("NA values filled!")

},
error = function(err)
{
message("An Error occured!")
message(toString(err))
stop(toString(err$message))
})

return(data)
})

#' save result
save_result <- Process$new(
id = "save_result",
Expand Down
18 changes: 18 additions & 0 deletions man/Collection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/array_interpolate_linear.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eac9afd

Please sign in to comment.