diff --git a/country_outputs/forest_biomass_summary_DRC_output.ipynb b/country_outputs/forest_biomass_summary_DRC_output.ipynb index 0022339f0354c6c63832273c5fdfc268c0051854..7bdc970e57784fb76f6b40b9fc6355a51a4e0228 100644 --- a/country_outputs/forest_biomass_summary_DRC_output.ipynb +++ b/country_outputs/forest_biomass_summary_DRC_output.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "multiple-shift", + "id": "domestic-poverty", "metadata": {}, "source": [ "# ESA Biomass Climate Change Initiative global forest aboveground biomass dataset v2.0 2010, 2017, 2018\n", @@ -18,7 +18,7 @@ }, { "cell_type": "markdown", - "id": "amended-providence", + "id": "unlimited-minnesota", "metadata": {}, "source": [ "#### Install these R packages first, and load them into the R session. Source R script with support functions." @@ -26,10 +26,175 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "packed-integral", - "metadata": {}, - "outputs": [], + "execution_count": 1, + "id": "exterior-nightmare", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Loading required package: raster\n", + "\n", + "Loading required package: sp\n", + "\n", + "Loading required package: rgdal\n", + "\n", + "rgdal: version: 1.5-23, (SVN revision 1121)\n", + "Geospatial Data Abstraction Library extensions to R successfully loaded\n", + "Loaded GDAL runtime: GDAL 3.3.2, released 2021/09/01\n", + "Path to GDAL shared files: /opt/conda/envs/r-with-gdal/share/gdal\n", + "GDAL binary built with GEOS: TRUE \n", + "Loaded PROJ runtime: Rel. 8.0.1, March 5th, 2021, [PJ_VERSION: 801]\n", + "Path to PROJ shared files: /opt/conda/envs/r-with-gdal/share/proj\n", + "PROJ CDN enabled: TRUE\n", + "Linking to sp version:1.4-5\n", + "To mute warnings of possible GDAL/OSR exportToProj4() degradation,\n", + "use options(\"rgdal_show_exportToProj4_warnings\"=\"none\") before loading rgdal.\n", + "\n", + "Loading required package: rgeos\n", + "\n", + "Warning message in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :\n", + "“there is no package called ‘rgeos’â€\n", + "also installing the dependencies ‘foreign’, ‘maptools’, ‘maps’\n", + "\n", + "\n", + "Updating HTML index of packages in '.Library'\n", + "\n", + "Making 'packages.html' ...\n", + " done\n", + "\n", + "rgeos version: 0.5-8, (SVN revision 679)\n", + " GEOS runtime version: 3.9.1-CAPI-1.14.2 \n", + " Please note that rgeos will be retired by the end of 2023,\n", + "plan transition to sf functions using GEOS at your earliest convenience.\n", + " GEOS using OverlayNG\n", + " Linking to sp version: 1.4-5 \n", + " Polygon checking: TRUE \n", + "\n", + "\n", + "Loading required package: geosphere\n", + "\n", + "Warning message in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :\n", + "“there is no package called ‘geosphere’â€\n", + "Updating HTML index of packages in '.Library'\n", + "\n", + "Making 'packages.html' ...\n", + " done\n", + "\n", + "Loading required package: RColorBrewer\n", + "\n", + "Loading required package: gdalUtils\n", + "\n", + "Loading required package: ff\n", + "\n", + "Warning message in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :\n", + "“there is no package called ‘ff’â€\n", + "also installing the dependency ‘biglm’\n", + "\n", + "\n", + "Updating HTML index of packages in '.Library'\n", + "\n", + "Making 'packages.html' ...\n", + " done\n", + "\n", + "\n", + "Attaching package: ‘bit’\n", + "\n", + "\n", + "The following object is masked from ‘package:rgeos’:\n", + "\n", + " symdiff\n", + "\n", + "\n", + "The following object is masked from ‘package:base’:\n", + "\n", + " xor\n", + "\n", + "\n", + "Attaching package ff\n", + "\n", + "- getOption(\"fftempdir\")==\"/tmp/RtmpPRaI0t/ff\"\n", + "\n", + "\n", + "- getOption(\"ffextension\")==\"ff\"\n", + "\n", + "\n", + "- getOption(\"ffdrop\")==TRUE\n", + "\n", + "\n", + "- getOption(\"fffinonexit\")==TRUE\n", + "\n", + "\n", + "- getOption(\"ffpagesize\")==65536\n", + "\n", + "\n", + "- getOption(\"ffcaching\")==\"mmnoflush\" -- consider \"ffeachflush\" if your system stalls on large writes\n", + "\n", + "\n", + "- getOption(\"ffbatchbytes\")==16777216 -- consider a different value for tuning your system\n", + "\n", + "\n", + "- getOption(\"ffmaxbytes\")==536870912 -- consider a different value for tuning your system\n", + "\n", + "\n", + "\n", + "Attaching package: ‘ff’\n", + "\n", + "\n", + "The following objects are masked from ‘package:raster’:\n", + "\n", + " filename, is.factor, ncol<-, nrow<-\n", + "\n", + "\n", + "The following objects are masked from ‘package:utils’:\n", + "\n", + " write.csv, write.csv2\n", + "\n", + "\n", + "The following objects are masked from ‘package:base’:\n", + "\n", + " is.factor, is.ordered\n", + "\n", + "\n", + "Loading required package: parallel\n", + "\n", + "Loading required package: snow\n", + "\n", + "Warning message in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :\n", + "“there is no package called ‘snow’â€\n", + "Warning message:\n", + "“dependency ‘nws’ is not availableâ€\n", + "also installing the dependencies ‘Rmpi’, ‘rlecuyer’\n", + "\n", + "\n", + "Warning message in install.packages(x, dependencies = TRUE):\n", + "“installation of package ‘Rmpi’ had non-zero exit statusâ€\n", + "Updating HTML index of packages in '.Library'\n", + "\n", + "Making 'packages.html' ...\n", + " done\n", + "\n", + "\n", + "Attaching package: ‘snow’\n", + "\n", + "\n", + "The following objects are masked from ‘package:parallel’:\n", + "\n", + " clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,\n", + " clusterExport, clusterMap, clusterSplit, makeCluster, parApply,\n", + " parCapply, parLapply, parRapply, parSapply, splitIndices,\n", + " stopCluster\n", + "\n", + "\n" + ] + } + ], "source": [ "packages <- c(\"raster\", \"rgdal\", \"rgeos\", \"geosphere\",\"RColorBrewer\",\"gdalUtils\",\"ff\",\"parallel\", \"snow\")\n", "package.check <- lapply(packages, FUN = function(x) {\n", @@ -44,7 +209,7 @@ }, { "cell_type": "markdown", - "id": "floral-miracle", + "id": "united-district", "metadata": {}, "source": [ "#### Set the path to the CCI Biomass data folder & read in world countries shapefile" @@ -52,14 +217,9 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "sunset-celebrity", - "metadata": { - "collapsed": true, - "jupyter": { - "outputs_hidden": true - } - }, + "execution_count": 2, + "id": "searching-deployment", + "metadata": {}, "outputs": [ { "name": "stdout", @@ -101,7 +261,7 @@ }, { "cell_type": "markdown", - "id": "smaller-accent", + "id": "fifteen-wedding", "metadata": {}, "source": [ "#### Generate 10x10 degree WGS84 grid that the CCI Biomass and Hansen Forest Cover products are tiled on" @@ -109,8 +269,8 @@ }, { "cell_type": "code", - "execution_count": 17, - "id": "written-chancellor", + "execution_count": 3, + "id": "sacred-rings", "metadata": {}, "outputs": [ { @@ -132,7 +292,7 @@ }, { "cell_type": "markdown", - "id": "minimal-think", + "id": "german-device", "metadata": {}, "source": [ "#### Print out country names in Africa to select from" @@ -140,8 +300,8 @@ }, { "cell_type": "code", - "execution_count": 22, - "id": "compressed-population", + "execution_count": 6, + "id": "developmental-aruba", "metadata": {}, "outputs": [ { @@ -449,7 +609,7 @@ }, { "cell_type": "markdown", - "id": "filled-german", + "id": "bigger-racing", "metadata": {}, "source": [ "#### Select a country in Africa to plot with corresponding data tiles" @@ -457,8 +617,8 @@ }, { "cell_type": "code", - "execution_count": 27, - "id": "offshore-allergy", + "execution_count": 7, + "id": "chronic-packing", "metadata": {}, "outputs": [ { @@ -509,7 +669,7 @@ " tiles <- cci_tiles[intersecting,]\n", " }\n", "\n", - "plot(Africa, col=\"gray\", main=iso3)\n", + "plot(Cont, col=\"gray\", main=iso3)\n", "plot(cci_tiles, lty=2, add=T)\n", "plot(tiles, lwd=2, border=\"red\", add=T)\n", "plot(aoi, col=\"red\", add=T)" @@ -517,8 +677,8 @@ }, { "cell_type": "code", - "execution_count": 29, - "id": "expected-thumbnail", + "execution_count": 8, + "id": "likely-reflection", "metadata": {}, "outputs": [], "source": [ @@ -528,7 +688,7 @@ }, { "cell_type": "markdown", - "id": "latin-hardware", + "id": "emotional-consistency", "metadata": {}, "source": [ "#### Read in the CCI Biomass data for this AOI from the downloaded CCI Biomass tiles, mosaicing multiple tiles as necessary" @@ -536,8 +696,8 @@ }, { "cell_type": "code", - "execution_count": 30, - "id": "classical-remainder", + "execution_count": 9, + "id": "honey-stewart", "metadata": {}, "outputs": [ { @@ -548,7 +708,7 @@ "resolution : 0.0008888889, 0.0008888889 (x, y)\n", "extent : 12.21067, 31.28089, -13.45867, 5.375111 (xmin, xmax, ymin, ymax)\n", "crs : +proj=longlat +datum=WGS84 +no_defs \n", - "source : r_tmp_2021-10-18_180804_880_66008.tif \n", + "source : r_tmp_2021-10-25_142438_1337_91161.tif \n", "names : agbd_2020, agbd_sd_2020 \n", "min values : 0, 0 \n", "max values : 552, 1068 \n" @@ -565,7 +725,7 @@ }, { "cell_type": "markdown", - "id": "interpreted-package", + "id": "careful-delivery", "metadata": {}, "source": [ "#### Read in the NCEO Biomass data for this AOI from the downloaded data. NCEO data is stored as a single file for the continent of Africa, rather than multiple tiles." @@ -573,10 +733,36 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "polished-offset", + "execution_count": 13, + "id": "fatty-activation", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1] \"/projects/shared-buckets/minord/data/nceo_africa_biomass/AGB_map_2017v0.tif\" \n", + "[2] \"/projects/shared-buckets/minord/data/nceo_africa_biomass/SD_AGB_map_2017v0.tif\"\n" + ] + }, + { + "data": { + "text/plain": [ + "class : RasterBrick \n", + "dimensions : 20966, 21228, 445066248, 2 (nrow, ncol, ncell, nlayers)\n", + "resolution : 0.0008983153, 0.0008983153 (x, y)\n", + "extent : 12.2108, 31.28024, -13.45856, 5.375519 (xmin, xmax, ymin, ymax)\n", + "crs : +proj=longlat +datum=WGS84 +no_defs \n", + "source : r_tmp_2021-10-25_145108_1337_50743.grd \n", + "names : agbd_2017, agbd_sd_2017 \n", + "min values : 0, 0 \n", + "max values : 730, 310 \n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "file_name <- paste0('AGB_map_2017v0.tif')\n", "file_name_sd <- paste0('SD_AGB_map_2017v0.tif')\n", @@ -609,11 +795,47 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "injured-ability", + "execution_count": 14, + "id": "hawaiian-bargain", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ERROR", + "evalue": "Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': invalid layer names\n", + "output_type": "error", + "traceback": [ + "Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': invalid layer names\nTraceback:\n", + "1. plot(cci$agbd_2017, main = \"CCI AGBD 2017\", zlim = c(0, 700))", + "2. cci$agbd_2017", + "3. cci$agbd_2017", + "4. x[[name]]", + "5. x[[name]]", + "6. .local(x, i, j, ...)", + "7. subset(x, i, drop = drop)", + "8. subset(x, i, drop = drop)", + "9. .local(x, ...)", + "10. stop(\"invalid layer names\")", + "11. .handleSimpleError(function (cond) \n . .Internal(C_tryCatchHelper(addr, 1L, cond)), \"invalid layer names\", \n . base::quote(.local(x, ...)))", + "12. h(simpleError(msg, call))" + ] + }, + { + "ename": "ERROR", + "evalue": "Error in polypath(x = mcrds[, 1], y = mcrds[, 2], border = border, col = col, : plot.new has not been called yet\n", + "output_type": "error", + "traceback": [ + "Error in polypath(x = mcrds[, 1], y = mcrds[, 2], border = border, col = col, : plot.new has not been called yet\nTraceback:\n", + "1. plot(aoi, add = T)", + "2. plot(aoi, add = T)", + "3. plot.SpatialPolygons(x, ...)", + "4. .polygonRingHoles(polys[[j]], col = col[j], border = border[j], \n . xpd = xpd, pbg = pbg, lty = lty, ..., usePolypath = usePolypath, \n . rule = rule)", + "5. polypath(x = mcrds[, 1], y = mcrds[, 2], border = border, col = col, \n . lty = lty, rule = rule, xpd = xpd, ...)" + ] + } + ], "source": [ + "# Fix this cell\n", + "\n", "par(mfrow=c(2,2), mai=c(0.5,0.5,0.5,0.5))\n", "options(repr.plot.width=10, repr.plot.height=10)\n", "plot(cci$agbd_2017, main=\"CCI AGBD 2017\", zlim = c(0,700)); plot(aoi, add=T)\n", @@ -624,7 +846,7 @@ }, { "cell_type": "markdown", - "id": "compound-louisville", + "id": "caroline-infrared", "metadata": {}, "source": [ "#### Calculate total aboveground biomass and average aboveground biomass density for 2017 CCI and NCEO biomass for the selected country" @@ -633,7 +855,7 @@ { "cell_type": "code", "execution_count": null, - "id": "inner-majority", + "id": "sophisticated-photographer", "metadata": {}, "outputs": [], "source": [ @@ -777,7 +999,7 @@ }, { "cell_type": "markdown", - "id": "impossible-banks", + "id": "continuing-crest", "metadata": {}, "source": [ "#### Print out basic forest aboveground biomass statistics for the selected country\n", @@ -787,7 +1009,7 @@ { "cell_type": "code", "execution_count": null, - "id": "endless-platinum", + "id": "professional-vertical", "metadata": {}, "outputs": [], "source": [ @@ -798,7 +1020,7 @@ { "cell_type": "code", "execution_count": null, - "id": "young-repeat", + "id": "premier-wallace", "metadata": {}, "outputs": [], "source": [ @@ -832,7 +1054,7 @@ { "cell_type": "code", "execution_count": null, - "id": "architectural-halloween", + "id": "statutory-chess", "metadata": {}, "outputs": [], "source": [ @@ -843,7 +1065,7 @@ { "cell_type": "code", "execution_count": null, - "id": "constitutional-output", + "id": "dedicated-grass", "metadata": {}, "outputs": [], "source": [ @@ -853,7 +1075,7 @@ { "cell_type": "code", "execution_count": null, - "id": "typical-falls", + "id": "signal-tractor", "metadata": {}, "outputs": [], "source": [ @@ -863,7 +1085,7 @@ { "cell_type": "code", "execution_count": null, - "id": "distant-scenario", + "id": "focal-trunk", "metadata": {}, "outputs": [], "source": [] @@ -871,7 +1093,7 @@ { "cell_type": "code", "execution_count": null, - "id": "nervous-expert", + "id": "several-spokesman", "metadata": {}, "outputs": [], "source": []