Created
August 28, 2021 00:12
-
-
Save csaybar/311cb07bca1eeac9da439e0448112c9f to your computer and use it in GitHub Desktop.
<<<<>>>>>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(jsonlite) | |
scribble_ano <- function(file) { | |
segmentation_point <- jsonlite::read_json(file) | |
segmentation_point$classes <- list( | |
list( | |
name = "Clear", | |
description = "All clear pixels, i.e. without cloud contamination or cloud shadows.", | |
colour = c(255, 255, 255, 0), | |
user_colour = c(0, 255, 255, 85) | |
), | |
list( | |
name = "Thick Cloud - C", | |
description = "All clear pixels, i.e. without cloud contamination or cloud shadows.", | |
colour = c(255, 255, 0, 85) | |
), | |
list( | |
name = "Thick Cloud - E", | |
description = "All clear pixels, i.e. without cloud contamination or cloud shadows.", | |
colour = c(150, 105, 0, 85) | |
), | |
list( | |
name = "Thin Cloud - C", | |
description = "All clear pixels, i.e. without cloud contamination or cloud shadows.", | |
colour = c(0, 255, 0, 85) | |
), | |
list( | |
name = "Thin Cloud - E", | |
description = "All clear pixels, i.e. without cloud contamination or cloud shadows.", | |
colour = c(50, 255, 200, 95) | |
), | |
list( | |
name = "Cloud Shadows - C", | |
description = "All pixels contaminated by cloud shadows (not terrain shadows).", | |
colour = c(255, 0, 0, 85) | |
), | |
list( | |
name = "Cloud Shadows - E", | |
description = "All pixels contaminated by cloud shadows (not terrain shadows).", | |
colour = c(100, 0, 0, 85) | |
), | |
list( | |
name = "No data", | |
description = "Reserved for no data pixels, e.g. pixels outside of the satellite's swath.", | |
colour = c(50, 50, 255, 85) | |
) | |
) | |
jsonlite::write_json( | |
x = segmentation_point, | |
path = file, | |
auto_unbox = T | |
) | |
invisible(TRUE) | |
} | |
get_json_files <- function(PATH) { | |
geoson_files <- list.files(path = PATH, full.names = TRUE) | |
json_files <- foreach (index=seq_along(geoson_files), .combine = c) %do% { | |
list.files(geoson_files[index], "cloud_segmentation_point", full.names = TRUE) | |
} | |
return(json_files) | |
} | |
PATH <- "/media/csaybar/Elements SE/cloudSEN12/scribble/" | |
cloud_json_files <- get_json_files(PATH) | |
sapply(cloud_json_files, scribble_ano) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment