Skip to content

Commit

Permalink
collection class refactored
Browse files Browse the repository at this point in the history
rewritten collection class
  • Loading branch information
PondiB authored Jan 27, 2024
2 parents 396dd55 + 9fb12ae commit cca8945
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 223 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Imports:
gdalcubes,
rstac
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Collate:
'api_process_graphs.R'
'api_job.R'
Expand Down
161 changes: 65 additions & 96 deletions R/Collection-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,30 @@ Collection <- R6Class(
id = NULL,
title = NULL,
description = NULL,
spatialExtent = NULL,
temporalExtent = NULL,
bands = NULL,
constellation = NULL,

#' @description Initialize collection
#'
#' @param id Id of the collection
#' @param title Collection title
#' @param description Short description of the collection
#' @param spatialExtent Spatial extent of the collection
#' @param temporalExtent Temporal extent of the collection
#' @param bands Bands of the collection
#'
initialize = function(id = NA, title = NA, description = NA) {

initialize = function(id = NA, title = NA, description = NA, spatialExtent = NA, temporalExtent = NA, bands = NA, constellation = NA) {
self$id = id
self$title = title
self$description = description
self$spatialExtent = spatialExtent
self$temporalExtent = temporalExtent
self$bands = bands
self$constellation = constellation
},

#' @description Add image collection to the collection class object
#'
#' @param ImageCollection Collection of class 'image collection'
#'
setCollection = function(ImageCollection) {
if (! gdalcubes:::is.image_collection(ImageCollection)) {
stop("Assigned data is not an image collection")
}

private$imageCollection = ImageCollection
self$setMetadata()
},

#' @description Get assigned image collection
#'
#' @return image collection
#'
getCollection = function() {
return(private$imageCollection)
},

#' @description add extent and bands to the metadata of the collection object
#'
setMetadata = function() {

private$metadata = list(
extent = extent(private$imageCollection),
bands = gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name
)
},

#' @description Get metadata of the collection
#'
#' @return metadata of the collection
#'
getMetadata = function() {
return(private$metadata)
},

#' @description Convert bandlist to be openeo compliant
#'
#' @return converted bandlist
#'
getEoBands = function() {

list = list()
bands = as.list(self$getMetadata()$bands)
list = lapply(bands, function(x) {
append(list, list(name = x))
})
return(list)
},

#' @description List metadata for the collection handler
#'
collectionInfo = function() {
list(
stac_version = Session$getConfig()$stac_version,
Expand All @@ -92,29 +47,26 @@ Collection <- R6Class(
license = "proprietary",
extent = list(
spatial = list(
bbox = list(list(self$getMetadata()$extent$left, self$getMetadata()$extent$bottom,
self$getMetadata()$extent$right, self$getMetadata()$extent$top))
bbox = list(self$spatialExtent)
),
temporal = list(
interval = list(list(self$getMetadata()$extent$t0, self$getMetadata()$extent$t1))
interval = list(self$temporalExtent)
)
),
links = list(
list(
rel = "self",
href = paste(Session$getConfig()$base_url, "collections", self$id, sep = "/")
),
list(
rel = "parent",
href = paste(Session$getConfig()$base_url, "collections", sep = "/")
))
links = list(
list(
rel = "self",
href = paste(Session$getConfig()$base_url, "collections", self$id, sep = "/")
),
list(
rel = "parent",
href = paste(Session$getConfig()$base_url, "collections", sep = "/")
)
)
)
},

#' @description List extended metadata for the collection handler
#'
collectionInfoExtended = function() {

list(
stac_version = Session$getConfig()$stac_version,
stac_extensions = list(Session$getConfig()$stac_extensions),
Expand All @@ -124,46 +76,44 @@ Collection <- R6Class(
license = "proprietary",
extent = list(
spatial = list(
bbox = list(list(self$getMetadata()$extent$left, self$getMetadata()$extent$bottom,
self$getMetadata()$extent$right, self$getMetadata()$extent$top))
bbox = list(self$spatialExtent)
),
temporal = list(
interval = list(list(self$getMetadata()$extent$t0, self$getMetadata()$extent$t1))
interval = list(self$temporalExtent)
)
),
links = list(list(
rel = "root",
href = paste(Session$getConfig()$base_url, "collections", sep = "/"))
links = list(
list(
rel = "root",
href = paste(Session$getConfig()$base_url, "collections", sep = "/")
)
),
"cube:dimensions" = list(
x = list(
type = "spatial",
axis = "x",
extent = list(self$getMetadata()$extent$left, self$getMetadata()$extent$right
)
extent = list(self$spatialExtent[1], self$spatialExtent[3])
),
y = list(
type = "spatial",
axis = "y",
extent = list(self$getMetadata()$extent$bottom, self$getMetadata()$extent$top
)
extent = list(self$spatialExtent[2], self$spatialExtent[4])
),
t = list(
type = "temporal",
extent = list(self$getMetadata()$extent$t0, self$getMetadata()$extent$t1)
extent = self$temporalExtent
),
bands = list(
type = "bands",
values = list(self$getMetadata()$bands)
values = self$bands
)
),
summaries = list(constellation = list(""), 'eo:bands' = self$getEoBands())
summaries = list(
constellation = list(self$constellation),
'eo:bands' = self$bands
)
)
}
),
private = list(
imageCollection = NULL,
metadata = NULL
)
)

Expand All @@ -172,31 +122,50 @@ is.Collection = function(obj) {
return("Collection" %in% class(obj))
}

# Example collections
# Instantiate collections

#'sentinel-s2-l2a-cogs
sentinel_s2_l2a_cogs <- Collection$new(
id = "sentinel-s2-l2a-cogs",
title = "Sentinel 2 L2A COGs",
description = "Sentinel-2a and Sentinel-2b imagery, processed to Level 2A (Surface Reflectance) and converted to Cloud-Optimized GeoTIFFs."
description = "Sentinel-2a and Sentinel-2b imagery, processed to Level 2A (Surface Reflectance) and converted to Cloud-Optimized GeoTIFFs.",
spatialExtent = list(-180, -90, 180, 90),
temporalExtent = list("2015-06-27T10:25:31.456000Z", "null"),
bands = c("B01", "B02", "B03", "B04", "B05", "B06", "B07", "B8", "B8A", "B9", "B10", "B11", "B12", "AOT", "WVP","SCL"),
constellation = list("sentinel-2")
)

#'sentinel-s2-l2a
# sentinel-s2-l2a
sentinel_s2_l2a <- Collection$new(
id = "sentinel-s2-l2a",
title = "Sentinel 2 L2A",
description = "Sentinel-2a and Sentinel-2b imagery, processed to Level 2A (Surface Reflectance)."
description = "Sentinel-2a and Sentinel-2b imagery, processed to Level 2A (Surface Reflectance).",
spatialExtent = list(-180, -90, 180, 90),
temporalExtent = list("2015-06-27T10:25:31.456000Z", "null"),
bands = c("B01", "B02", "B03", "B04", "B05", "B06", "B07", "B8", "B8A", "B9", "B10", "B11", "B12", "AOT", "WVP","SCL"),
constellation = list("sentinel-2")
)

#'sentinel-s2-l1c

# sentinel-s2-l1c
sentinel_s2_l1c <- Collection$new(
id = "sentinel-s2-l1c",
title = "Sentinel 2 L1C",
description = "Sentinel-2a and Sentinel-2b imagery, processed to Level 1C (Top-Of-Atmosphere Geometrically Corrected)."
description = "Sentinel-2a and Sentinel-2b imagery, processed to Level 1C (Top-Of-Atmosphere Geometrically Corrected).",
spatialExtent = list(-180, -90, 180, 90),
temporalExtent = list("2015-06-27T10:25:31.456000Z","null"),
bands = c("B01", "B02", "B03", "B04", "B05", "B06", "B07", "B8", "B8A", "B9", "B10", "B11", "B12"),
constellation = list("sentinel-2")
)

#'landsat-8-l1-c1
# landsat-8-l1-c1
landsat_8_l1_c1 <- Collection$new(
id = "landsat-8-l1-c1",
title = "Landsat-8 L1 Collection-1",
description = "Landat-8 L1 Collection-1 imagery radiometrically calibrated and orthorectified using gound points and Digital Elevation Model (DEM) data to correct relief displacement."
description = "Landat-8 L1 Collection-1 imagery radiometrically calibrated and orthorectified using ground points and Digital Elevation Model (DEM) data to correct relief displacement.",
spatialExtent = list(-180, -90, 180, 90),
temporalExtent = list("2013-06-01T00:00:00Z", "null"),
bands = c("B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B8A", "B9", "B10", "B11"),
constellation = list("Landsat 8")
)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# OpenEOcubes: openEO Compliant Lightweight R Platform for Processing Satellite Image Time Series

The service integrates STAC API (using Rstac package), the OpenEO standardized API, and data cubes concepts (using gdalcubes R package) to be a lightweight platform to enable analysis of time series satellite images via OpenEO Compliant RESTful endpoints using R-Client. It also supports users to run their custom R functions.
The service integrates STAC API (using Rstac package), the OpenEO standardized API, and data cubes concepts (using gdalcubes R package) to be a lightweight platform to enable analysis of time series satellite images via OpenEO Compliant RESTful endpoints using R, Python and JavaScript Clients. It also supports users to run their custom R functions.

#### Motivation for the platform:
The service tries to improve on the limitations of established EO data management platforms like Google Earth Engine and Sentinel Hub by supporting:
Expand All @@ -11,7 +11,7 @@ The service tries to improve on the limitations of established EO data manageme
* Open Governance
* No Need for User Management
* User-Defined R Functions
* Flexibility - Custom CRS, and Quick Resampling of Massive EO Data
* Flexibility - Custom CRS,Quick Resampling of 'Large' EO Data


![](docs/openeocubes.png)
Expand All @@ -22,9 +22,9 @@ After processing the data , one can download and explore on open source tools l
#### Future developments:
Geospatial Machine Learning APIs for time-series EO Data:
* ML APIs e.g. Random Forest, SVM, XGBoost, etc.
* DL APIs e.g. TempCNN, ResNet, etc.
* DL APIs e.g. TempCNN, ResNet, LSTM etc.

Currently PoC is being worked on at [this reposity](https://github.com/Open-Earth-Monitor/openeosits) on the [Open Earth Monitor Cyberinfrastructure](https://earthmonitor.org/) EU funded project.
Currently, PoC for ML APIs is being worked under the [Open Earth Monitor Cyberinfrastructure](https://earthmonitor.org/) EU funded project.
## Easy Deployment from DockerHub
Assuming you have Docker installed. This is the easiest approach.
You can get a hosted Docker image of the platform on DockerHub
Expand Down
Loading

0 comments on commit cca8945

Please sign in to comment.