Please update the below path to the diagnostics folder on your computer
library(dplyr)
library(data.table)
library(testthat)
library(ggplot2)
library(scales)
package 㤼㸱scales㤼㸲 was built under R version 4.0.5
path_to_diagnostics_folder <- "C:/Projects/moirai/moirai/diagnostics/"
setwd(path_to_diagnostics_folder)
#Load all required scripts
#Load land test functions
source("Compare_LDS_area_outputs.R")
#Load carbon plot functions
source("Carbon_diagnostic_functions.R")
Loading required package: sp
Attaching package: 㤼㸱raster㤼㸲
The following object is masked from 㤼㸱package:data.table㤼㸲:
shift
The following object is masked from 㤼㸱package:dplyr㤼㸲:
select
The following object is masked from 㤼㸱package:tidyr㤼㸲:
extract
rgdal: version: 1.5-23, (SVN revision 1121)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29
Path to GDAL shared files: C:/Users/nara836/OneDrive - PNNL/Documents/R/win-library/4.0/rgdal/gdal
GDAL binary built with GEOS: TRUE
Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
Path to PROJ shared files: C:/Users/nara836/OneDrive - PNNL/Documents/R/win-library/4.0/rgdal/proj
PROJ CDN enabled: FALSE
Linking to sp version:1.4-5
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
Overwritten PROJ_LIB was C:/Users/nara836/OneDrive - PNNL/Documents/R/win-library/4.0/rgdal/proj
package 㤼㸱reldist㤼㸲 was built under R version 4.0.5Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
reldist: Relative Distribution Methods
Version 1.6-6 created on 2016-10-07.
copyright (c) 2003, Mark S. Handcock, University of California-Los Angeles
For citation information, type citation("reldist").
Type help(package="reldist") to get started.
In the examples below we have set the path_to_Original_LDS_Data & path_to_old_mapping to the new example_outputs. Please change this to the desired land outputs that you would like to compare against.
#Compare at the highest level (iso,year)
compare_iso_land_data(path_to_Original_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_Updated_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_old_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
path_to_new_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
error_tolerance= 0.01,
create_land_plot=TRUE
)
#Compare at iso_glu_data
compare_iso_glu_land_data(path_to_Original_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_Updated_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_old_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
path_to_new_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
error_tolerance= 0.01)
#Compare at the iso,glu,year level
compare_iso_glu_land_data(path_to_Original_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_Updated_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_old_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
path_to_new_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
error_tolerance= 0.01,
create_land_plot=TRUE)
#Compare at the hyde level
compare_iso_glu_hyde_land_data(path_to_Original_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_Updated_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_old_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
path_to_new_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
error_tolerance= 0.01,
create_land_plot=TRUE,
print_difference_stats=TRUE,
absolute_diff_tolerance=3,
percent_diff_tolerance=0.5)
#Compare at iso, glu_sage level
compare_iso_glu_sage_land_data(path_to_Original_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_Updated_LDS_Data = "../example_outputs/basins235/Land_type_area_ha.csv",
path_to_old_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
path_to_new_mapping = "../example_outputs/basins235/MOIRAI_land_types.csv",
error_tolerance= 0.01,
create_land_plot=TRUE,
print_difference_stats=TRUE,
absolute_diff_tolerance=3,
percent_diff_tolerance=0.5)
scheme_basic <- theme_bw() +
theme(legend.text = element_text(size = 15)) +
theme(legend.title = element_text(size = 15)) +
theme(axis.text = element_text(size = 18)) +
theme(axis.title = element_text(size = 18, face = "bold")) +
theme(plot.title = element_text(size = 15, face = "bold", vjust = 1)) +
theme(plot.subtitle = element_text(size = 9, face = "bold", vjust = 1))+
theme(strip.text = element_text(size = 7))+
theme(strip.text.x = element_text(size = 18, face = "bold"))+
theme(strip.text.y = element_text(size = 15, face = "bold"))+
theme(legend.position = "bottom")+
theme(legend.text = element_text(size = 12))+
theme(legend.title = element_text(size = 12,color = "black",face="bold"))+
theme(axis.text.x= element_text(hjust=1))+
theme(legend.background = element_blank(),
legend.box.background = element_rect(colour = "black"))
moirai_land_classes <- read.csv("../ancillary/carbon_harmonization/input_files/ESA_moirai_classes.csv")
for (i in c("TropicalEvergreenForest/Woodland",
"Savanna",
"Grassland/Steppe")){
c_type <- "AG"
g <- compare_carbon_distribution_ESA(carbon_type = c_type,
basin_for_testing = "Amazon",
moirai_LC = i,
harmonized_carbon_raster_file_names = c("AG_carbon_q1.envi",
"AG_carbon_q3.envi",
"AG_carbon_median.envi",
"AG_carbon_min.envi",
"AG_carbon_max.envi",
"AG_carbon_weighted_average.envi"),
plot_lim = 8000,
produce_ESA_distribution = FALSE)
name_for_plot <- gsub("/","_",i)
ggsave(plot= g+ scheme_basic ,filename= paste0("carbon_plots/",c_type,name_for_plot,"Amazon", ".jpeg"), width = 10, height = 6, device= "jpeg")
}
no non-missing arguments to min; returning Infno non-missing arguments to max; returning -Infattributes are not identical across measure variables;
they will be droppedDiscarded datum D_Unknown_based_on_WGS84_ellipsoid in Proj4 definition: +proj=longlat +ellps=WGS84 +no_defsDiscarded datum Unknown based on WGS84 ellipsoid in Proj4 definitionError in .local(.Object, ...) :
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': error in evaluating the argument 'x' in selecting a method for function 'nlayers': Cannot create a RasterLayer object from this file.