Created
January 11, 2021 13:26
-
-
Save M3nin0/836615df59fbdefdc03cba6ca9d34330 to your computer and use it in GitHub Desktop.
Script to randomly select 80 sample points from the data set provided in https://doi.pangaea.de/10.1594/PANGAEA.921387
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
# Adapted from: https://github.com/albhasan/deforestation-sentinel2/blob/master/06_validation/validate_results.R | |
# validation_dataset_bands.csv is avaliable online on: https://doi.pangaea.de/10.1594/PANGAEA.921387?format=html#download | |
set.seed(666) | |
validation_dataset_bands <- readr::read_csv("validation_dataset_bands.csv") | |
deforestation <- dplyr::filter(validation_dataset_bands, label == "Deforestation") | |
non_forest <- dplyr::filter(validation_dataset_bands, label == "Non-Forest") | |
forest <- dplyr::filter(validation_dataset_bands, label == "Forest") | |
deforestation_80 <- dplyr::sample_n(deforestation, 80) | |
non_forest_80 <- dplyr::sample_n(non_forest, 80) | |
forest_80 <- dplyr::sample_n(forest, 80) | |
validation_dataset_bands <- rbind(deforestation_80, non_forest_80, forest_80) | |
samples_data <- validation_dataset_bands[sample(nrow(validation_dataset_bands)), ] | |
write.csv(samples_data, "validation_dataset_bands_80.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment