diff --git a/.ipynb_checkpoints/plot2map_Mexico_demo-checkpoint.ipynb b/.ipynb_checkpoints/plot2map_Mexico_demo-checkpoint.ipynb index 6d7189dd54eadc69b08350e3cf994279e3079c3c..f868b8e2db68d616e1a7a8f03758c49ba7d67ed7 100644 --- a/.ipynb_checkpoints/plot2map_Mexico_demo-checkpoint.ipynb +++ b/.ipynb_checkpoints/plot2map_Mexico_demo-checkpoint.ipynb @@ -55,7 +55,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "judicial-mathematics", "metadata": { "tags": [] @@ -69,113 +69,14 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "55e7d789-a39e-4eed-a5a3-8a2adb9f676f", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "also installing the dependencies ‘systemfonts’, ‘svglite’, ‘terra’, ‘leafem’, ‘leafpop’, ‘raster’, ‘tmaptools’, ‘units’, ‘lwgeom’, ‘mapview’, ‘pool’, ‘stars’, ‘tmap’\n", - "\n", - "\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘systemfonts’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘terra’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘units’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘pool’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘svglite’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘raster’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘sf’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘leafem’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘leafpop’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘lwgeom’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘stars’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘tmaptools’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘mapview’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘tmap’ had non-zero exit statusâ€\n", - "Updating HTML index of packages in '.Library'\n", - "\n", - "Making 'packages.html' ...\n", - " done\n", - "\n" - ] - }, - { - "ename": "ERROR", - "evalue": "Error in library(sf): there is no package called ‘sf’\n", - "output_type": "error", - "traceback": [ - "Error in library(sf): there is no package called ‘sf’\nTraceback:\n", - "1. library(sf)" - ] - } - ], - "source": [ - "install.packages('sf', dependencies=T)\n", - "library(sf)" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "de9cb90c-07f0-4099-896a-909dccbf21ac", + "execution_count": 4, + "id": "85854ef6-72e1-4091-a764-5e8e0c58ef28", "metadata": { "tags": [] }, - "outputs": [ - { - "ename": "ERROR", - "evalue": "Error in library(sf): there is no package called ‘sf’\n", - "output_type": "error", - "traceback": [ - "Error in library(sf): there is no package called ‘sf’\nTraceback:\n", - "1. library(sf)" - ] - } - ], - "source": [ - "library(ranger)\n", - "library(rgdal)\n", - "library(terra)\n", - "library(stringr)\n", - "library(sf)\n", - "library(plyr)\n", - "library(dplyr)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "7947548a-28c5-4d4c-a7e1-9d55598fc872", - "metadata": {}, - "outputs": [ - { - "ename": "ERROR", - "evalue": "Error in library(sf): there is no package called ‘sf’\n", - "output_type": "error", - "traceback": [ - "Error in library(sf): there is no package called ‘sf’\nTraceback:\n", - "1. library(sf)" - ] - } - ], + "outputs": [], "source": [ - "library(sf)" + "## Go to Terminal to install sf manually using mamba see guide doc" ] }, { @@ -199,9 +100,9 @@ "AGBown <- NA #if user-derived AGB map is to be validated\n", "fmask <- NA #if country forest map is to be used\n", "\n", - "agbTilesDir <- \"/projects/shared-buckets/minord/data/cci_biomass/v3.0/2020\"\n", - "treeCoverDir <-'/projects/shared-buckets/arnanaraza/treecover2010_v3' \n", - "biasCovsDir <-'/projects/shared-buckets/arnanaraza/bias_modelling_covs' \n", + "agbTilesDir <- dataDir #for now\n", + "treeCoverDir <- dataDir\n", + "biasCovsDir <-dataDir \n", "\n", "# Load all the functions needed\n", "setwd(scriptsDir) \n", @@ -257,7 +158,7 @@ "setwd(dataDir)\n", "plotsFile <- 'NFI_Mexico_DeJong2014.csv'\n", "plots <- read.csv(plotsFile) \n", - "world <- readOGR(\"/projects/shared-buckets/leitoldv/NaturalEarth/ne_10m_admin_0_countries.shp\")\n", + "world <- readOGR(\"ne_10m_admin_0_countries.shp\")\n", "mexico <- world[world$ADM0_A3==\"MEX\",]\n", "plot(mexico)\n", "p <- plots\n", @@ -1628,7 +1529,7 @@ "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", - "version": "4.1.3" + "version": "4.2.3" } }, "nbformat": 4, diff --git a/plot2map_Mexico_demo.ipynb b/plot2map_Mexico_demo.ipynb index 6d7189dd54eadc69b08350e3cf994279e3079c3c..f868b8e2db68d616e1a7a8f03758c49ba7d67ed7 100644 --- a/plot2map_Mexico_demo.ipynb +++ b/plot2map_Mexico_demo.ipynb @@ -55,7 +55,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "judicial-mathematics", "metadata": { "tags": [] @@ -69,113 +69,14 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "55e7d789-a39e-4eed-a5a3-8a2adb9f676f", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "also installing the dependencies ‘systemfonts’, ‘svglite’, ‘terra’, ‘leafem’, ‘leafpop’, ‘raster’, ‘tmaptools’, ‘units’, ‘lwgeom’, ‘mapview’, ‘pool’, ‘stars’, ‘tmap’\n", - "\n", - "\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘systemfonts’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘terra’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘units’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘pool’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘svglite’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘raster’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘sf’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘leafem’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘leafpop’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘lwgeom’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘stars’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘tmaptools’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘mapview’ had non-zero exit statusâ€\n", - "Warning message in install.packages(\"sf\", dependencies = T):\n", - "“installation of package ‘tmap’ had non-zero exit statusâ€\n", - "Updating HTML index of packages in '.Library'\n", - "\n", - "Making 'packages.html' ...\n", - " done\n", - "\n" - ] - }, - { - "ename": "ERROR", - "evalue": "Error in library(sf): there is no package called ‘sf’\n", - "output_type": "error", - "traceback": [ - "Error in library(sf): there is no package called ‘sf’\nTraceback:\n", - "1. library(sf)" - ] - } - ], - "source": [ - "install.packages('sf', dependencies=T)\n", - "library(sf)" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "de9cb90c-07f0-4099-896a-909dccbf21ac", + "execution_count": 4, + "id": "85854ef6-72e1-4091-a764-5e8e0c58ef28", "metadata": { "tags": [] }, - "outputs": [ - { - "ename": "ERROR", - "evalue": "Error in library(sf): there is no package called ‘sf’\n", - "output_type": "error", - "traceback": [ - "Error in library(sf): there is no package called ‘sf’\nTraceback:\n", - "1. library(sf)" - ] - } - ], - "source": [ - "library(ranger)\n", - "library(rgdal)\n", - "library(terra)\n", - "library(stringr)\n", - "library(sf)\n", - "library(plyr)\n", - "library(dplyr)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "7947548a-28c5-4d4c-a7e1-9d55598fc872", - "metadata": {}, - "outputs": [ - { - "ename": "ERROR", - "evalue": "Error in library(sf): there is no package called ‘sf’\n", - "output_type": "error", - "traceback": [ - "Error in library(sf): there is no package called ‘sf’\nTraceback:\n", - "1. library(sf)" - ] - } - ], + "outputs": [], "source": [ - "library(sf)" + "## Go to Terminal to install sf manually using mamba see guide doc" ] }, { @@ -199,9 +100,9 @@ "AGBown <- NA #if user-derived AGB map is to be validated\n", "fmask <- NA #if country forest map is to be used\n", "\n", - "agbTilesDir <- \"/projects/shared-buckets/minord/data/cci_biomass/v3.0/2020\"\n", - "treeCoverDir <-'/projects/shared-buckets/arnanaraza/treecover2010_v3' \n", - "biasCovsDir <-'/projects/shared-buckets/arnanaraza/bias_modelling_covs' \n", + "agbTilesDir <- dataDir #for now\n", + "treeCoverDir <- dataDir\n", + "biasCovsDir <-dataDir \n", "\n", "# Load all the functions needed\n", "setwd(scriptsDir) \n", @@ -257,7 +158,7 @@ "setwd(dataDir)\n", "plotsFile <- 'NFI_Mexico_DeJong2014.csv'\n", "plots <- read.csv(plotsFile) \n", - "world <- readOGR(\"/projects/shared-buckets/leitoldv/NaturalEarth/ne_10m_admin_0_countries.shp\")\n", + "world <- readOGR(\"ne_10m_admin_0_countries.shp\")\n", "mexico <- world[world$ADM0_A3==\"MEX\",]\n", "plot(mexico)\n", "p <- plots\n", @@ -1628,7 +1529,7 @@ "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", - "version": "4.1.3" + "version": "4.2.3" } }, "nbformat": 4, diff --git a/plot2map_allGabonVal_1km.ipynb b/plot2map_allGabonVal_1km.ipynb index 4a467f3eee376aa86182f21d2fb52e24f879dfb9..0532660bb711c12d15ec8bbaa02e6f7e78f06cf3 100644 --- a/plot2map_allGabonVal_1km.ipynb +++ b/plot2map_allGabonVal_1km.ipynb @@ -1714,9 +1714,9 @@ ], "metadata": { "kernelspec": { - "display_name": "R [conda env:r-with-gdal]", + "display_name": "R", "language": "R", - "name": "conda-env-r-with-gdal-r" + "name": "ir" }, "language_info": { "codemirror_mode": "r", @@ -1724,7 +1724,7 @@ "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", - "version": "4.1.1" + "version": "4.1.3" } }, "nbformat": 4, diff --git a/scripts/TileNames.R b/scripts/TileNames.R index 8a9377bd8edb26f11f2bc3dd82f3cb3530d3fa7a..163f2816155c53111be3daab0981d35e7e23395e 100644 --- a/scripts/TileNames.R +++ b/scripts/TileNames.R @@ -15,7 +15,7 @@ TCtileNames <- function(pol) { LtY <- ifelse(lat <= 0, "S", "N") # Adjusted for correct North/South designation WE <- paste0(sprintf('%03d', abs(lon)), LtX) NS <- paste0(sprintf('%02d', abs(lat)), LtY) - fnms <- c(fnms, file.path(treeCoverDir, paste0("treecover2010_", NS, "_", WE, ".tif"))) + fnms <- c(fnms, file.path(treeCoverDir, paste0("treecover2020_", NS, "_", WE, ".tif"))) } unique(fnms) @@ -37,7 +37,7 @@ AGBtileNames <- function(pol){ LtY <- ifelse(lat < 0, "S", "N") WE <- paste0(LtX, sprintf('%03d',abs(lon))) NS <- paste0(LtY,sprintf('%02d',abs(lat))) - fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2017-fv2.0.tif")) + fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2017-fv5.0.tif")) }else if (grepl('2010', agbTilesDir) == TRUE){ lon <- 10*(crds[i,1]%/%10) @@ -46,7 +46,7 @@ AGBtileNames <- function(pol){ LtY <- ifelse(lat < 0, "S", "N") WE <- paste0(LtX, sprintf('%03d',abs(lon))) NS <- paste0(LtY,sprintf('%02d',abs(lat))) - fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2010-fv2.0.tif")) + fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2010-fv5.0.tif")) }else if (grepl('2018', agbTilesDir) == TRUE){ lon <- 10*(crds[i,1]%/%10) lat <- 10*(crds[i,2]%/%10) + 10 @@ -54,7 +54,7 @@ AGBtileNames <- function(pol){ LtY <- ifelse(lat < 0, "S", "N") WE <- paste0(LtX, sprintf('%03d',abs(lon))) NS <- paste0(LtY,sprintf('%02d',abs(lat))) - fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2018-fv2.0.tif")) + fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2018-fv5.0.tif")) }else{ lon <- 10*(crds[i,1]%/%10) lat <- 10*(crds[i,2]%/%10) + 10 @@ -62,7 +62,7 @@ AGBtileNames <- function(pol){ LtY <- ifelse(lat < 0, "S", "N") WE <- paste0(LtX, sprintf('%03d',abs(lon))) NS <- paste0(LtY,sprintf('%02d',abs(lat))) - fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2020-fv3.0.tif")) + fnms[i] <- file.path(agbTilesDir, paste0(NS, WE,"_ESACCI-BIOMASS-L4-AGB-MERGED-100m-2020-fv5.0.tif")) } } fnms0 <- unique(grep(paste(match,collapse="|"), fnms, value=T))