From 43ff219882f1dd718f70a8d701b7e0365d4f94b4 Mon Sep 17 00:00:00 2001 From: tkerr1 <theodoremkerr@gmail.com> Date: Fri, 3 Dec 2021 02:02:19 +0000 Subject: [PATCH] Added some cells to resolve the disk overutilization issue --- .../forest_biomass_summary_DRC_output.ipynb | 223 ++++++++++-------- 1 file changed, 128 insertions(+), 95 deletions(-) diff --git a/country_outputs/forest_biomass_summary_DRC_output.ipynb b/country_outputs/forest_biomass_summary_DRC_output.ipynb index fa86cef..fe7f8c8 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": "narrow-lodge", + "id": "working-vision", "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": "answering-provision", + "id": "infectious-divorce", "metadata": {}, "source": [ "#### Install these R packages first, and load them into the R session. Source R script with support functions." @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "ordered-novel", + "id": "killing-april", "metadata": {}, "outputs": [ { @@ -54,6 +54,16 @@ "\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", @@ -65,13 +75,28 @@ "\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", - "Loading required package: bit\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", @@ -89,7 +114,7 @@ "\n", "Attaching package ff\n", "\n", - "- getOption(\"fftempdir\")==\"/tmp/RtmpMbrE16/ff\"\n", + "- getOption(\"fftempdir\")==\"/tmp/RtmpWvIQu8/ff\"\n", "\n", "\n", "- getOption(\"ffextension\")==\"ff\"\n", @@ -136,6 +161,16 @@ "\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", + "also installing the dependency ‘rlecuyer’\n", + "\n", + "\n", + "Updating HTML index of packages in '.Library'\n", + "\n", + "Making 'packages.html' ...\n", + " done\n", + "\n", "\n", "Attaching package: ‘snow’\n", "\n", @@ -165,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "assigned-mining", + "id": "juvenile-synthesis", "metadata": {}, "source": [ "#### Set the path to the CCI, JPL, and NCEO Biomass data folders & read in world countries shapefile" @@ -174,7 +209,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "homeless-blade", + "id": "experimental-dynamics", "metadata": {}, "outputs": [ { @@ -208,7 +243,7 @@ }, { "cell_type": "markdown", - "id": "vietnamese-calcium", + "id": "rocky-warning", "metadata": {}, "source": [ "#### Generate 10x10 degree WGS84 grid that the CCI Biomass and Hansen Forest Cover products are tiled on" @@ -217,7 +252,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "southeast-johnston", + "id": "decent-leadership", "metadata": {}, "outputs": [ { @@ -239,7 +274,7 @@ }, { "cell_type": "markdown", - "id": "fewer-dutch", + "id": "organized-dealing", "metadata": {}, "source": [ "#### Print out country names in Africa to select from" @@ -248,7 +283,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "intensive-assault", + "id": "smooth-burner", "metadata": {}, "outputs": [ { @@ -556,7 +591,7 @@ }, { "cell_type": "markdown", - "id": "different-serum", + "id": "prescription-accordance", "metadata": {}, "source": [ "#### Select a country in Africa to plot with corresponding data tiles" @@ -565,7 +600,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "operating-beatles", + "id": "isolated-preference", "metadata": {}, "outputs": [ { @@ -625,7 +660,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "medium-medication", + "id": "conditional-command", "metadata": {}, "outputs": [], "source": [ @@ -635,7 +670,7 @@ }, { "cell_type": "markdown", - "id": "other-governor", + "id": "historic-serum", "metadata": {}, "source": [ "#### Read in the CCI Biomass data for this AOI from the downloaded CCI Biomass tiles, mosaicing multiple tiles as necessary" @@ -644,7 +679,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "scheduled-arlington", + "id": "continental-check", "metadata": {}, "outputs": [ { @@ -655,7 +690,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-12-02_165408_9245_93637.tif \n", + "source : r_tmp_2021-12-03_014403_789_64087.tif \n", "names : agbd_2020, agbd_sd_2020 \n", "min values : 0, 0 \n", "max values : 552, 1068 \n" @@ -672,7 +707,7 @@ }, { "cell_type": "markdown", - "id": "immediate-playlist", + "id": "occupied-spectrum", "metadata": {}, "source": [ "#### Plot the CCI AGBD for 2020" @@ -681,7 +716,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "expired-doctrine", + "id": "separate-american", "metadata": {}, "outputs": [ { @@ -706,7 +741,7 @@ }, { "cell_type": "markdown", - "id": "scientific-screening", + "id": "pretty-portal", "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." @@ -715,7 +750,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "limiting-alexander", + "id": "peaceful-parallel", "metadata": {}, "outputs": [ { @@ -733,7 +768,7 @@ "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-12-02_165730_9245_75779.grd \n", + "source : r_tmp_2021-12-03_014816_789_46965.grd \n", "names : agbd_2017 \n", "min values : 0 \n", "max values : 730 \n" @@ -768,7 +803,7 @@ }, { "cell_type": "markdown", - "id": "boxed-electricity", + "id": "matched-focus", "metadata": {}, "source": [ "#### Plot the NCEO AGBD for 2017" @@ -777,7 +812,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "built-worry", + "id": "numerical-punch", "metadata": {}, "outputs": [ { @@ -803,7 +838,7 @@ }, { "cell_type": "markdown", - "id": "atlantic-installation", + "id": "derived-timer", "metadata": {}, "source": [ "#### Read in the JPL Biomass data for this AOI" @@ -812,7 +847,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "cutting-paint", + "id": "obvious-lewis", "metadata": {}, "outputs": [ { @@ -830,7 +865,7 @@ "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-12-02_165819_9245_94988.grd \n", + "source : r_tmp_2021-12-03_014936_789_16723.grd \n", "names : agbd_2020 \n", "min values : 0 \n", "max values : 24186 \n" @@ -871,7 +906,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "offshore-russia", + "id": "unlimited-volume", "metadata": {}, "outputs": [ { @@ -882,7 +917,7 @@ "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-12-02_170249_9245_84317.grd \n", + "source : r_tmp_2021-12-03_015433_789_81839.grd \n", "names : agbd_2020 \n", "values : 0, 1997.5 (min, max)\n" ] @@ -902,7 +937,7 @@ }, { "cell_type": "markdown", - "id": "fleet-brave", + "id": "essential-sarah", "metadata": {}, "source": [ "#### Plot the JPL AGBD for 2020" @@ -911,7 +946,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "banned-colony", + "id": "favorite-korean", "metadata": {}, "outputs": [ { @@ -936,7 +971,7 @@ }, { "cell_type": "markdown", - "id": "endangered-layout", + "id": "wooden-drinking", "metadata": {}, "source": [ "#### Read in forest cover raster. Currently using 30% forest cover from Hansen product. The cover rasters have been resampled to the resolutions of CCI Biomass, JPL Biomass, and NCEO Biomass for use as a forest cover mask." @@ -945,7 +980,7 @@ { "cell_type": "code", "execution_count": null, - "id": "smooth-decade", + "id": "deadly-closure", "metadata": {}, "outputs": [], "source": [ @@ -956,7 +991,7 @@ }, { "cell_type": "markdown", - "id": "urban-stick", + "id": "crazy-buffer", "metadata": {}, "source": [ "#### Create 30% cover forest threshold mask for CCI" @@ -965,7 +1000,7 @@ { "cell_type": "code", "execution_count": null, - "id": "steady-bones", + "id": "alpha-candidate", "metadata": {}, "outputs": [], "source": [ @@ -978,7 +1013,7 @@ }, { "cell_type": "markdown", - "id": "marine-silver", + "id": "strategic-pennsylvania", "metadata": {}, "source": [ "#### Create 30% cover forest threshold mask for JPL" @@ -987,7 +1022,7 @@ { "cell_type": "code", "execution_count": null, - "id": "canadian-crack", + "id": "quality-durham", "metadata": {}, "outputs": [], "source": [ @@ -1000,7 +1035,7 @@ }, { "cell_type": "markdown", - "id": "guided-terrace", + "id": "forward-diana", "metadata": {}, "source": [ "#### Create 30% cover forest threshold mask for NCEO" @@ -1009,7 +1044,7 @@ { "cell_type": "code", "execution_count": null, - "id": "typical-philip", + "id": "sophisticated-wound", "metadata": {}, "outputs": [], "source": [ @@ -1023,7 +1058,7 @@ { "cell_type": "code", "execution_count": 28, - "id": "strategic-taste", + "id": "pregnant-wrist", "metadata": {}, "outputs": [], "source": [ @@ -1034,7 +1069,7 @@ }, { "cell_type": "markdown", - "id": "advisory-america", + "id": "injured-cliff", "metadata": {}, "source": [ "### Checkpoint: Write out and read in Forest cover threshold mask for CCI and JPL" @@ -1043,7 +1078,7 @@ { "cell_type": "code", "execution_count": 29, - "id": "entertaining-blame", + "id": "derived-acrobat", "metadata": {}, "outputs": [], "source": [ @@ -1062,7 +1097,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "solid-terrace", + "id": "fabulous-finance", "metadata": {}, "outputs": [], "source": [ @@ -1084,7 +1119,7 @@ }, { "cell_type": "markdown", - "id": "amber-cursor", + "id": "intense-notice", "metadata": {}, "source": [ "#### Apply the forest cover threshold mask to CCI, JPL, and NCEO" @@ -1093,7 +1128,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "smart-spice", + "id": "north-capacity", "metadata": {}, "outputs": [ { @@ -1121,7 +1156,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "olive-onion", + "id": "isolated-trigger", "metadata": {}, "outputs": [ { @@ -1179,7 +1214,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "talented-emphasis", + "id": "democratic-integration", "metadata": {}, "outputs": [ { @@ -1207,7 +1242,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "marine-theology", + "id": "legitimate-lesbian", "metadata": {}, "outputs": [ { @@ -1265,7 +1300,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "spare-istanbul", + "id": "wound-space", "metadata": {}, "outputs": [ { @@ -1293,7 +1328,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "traditional-record", + "id": "exempt-lafayette", "metadata": {}, "outputs": [ { @@ -1350,7 +1385,7 @@ }, { "cell_type": "markdown", - "id": "suited-desperate", + "id": "limited-switzerland", "metadata": {}, "source": [ "### Checkpoint: Write out and read in Forest only biomass for CCI, JPL, and NCEO" @@ -1359,7 +1394,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "polished-regular", + "id": "promising-papua", "metadata": {}, "outputs": [], "source": [ @@ -1377,32 +1412,10 @@ }, { "cell_type": "code", - "execution_count": 25, - "id": "voluntary-fence", + "execution_count": 15, + "id": "heated-devon", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Error in .local(.Object, ...) : \n", - "\n" - ] - }, - { - "ename": "ERROR", - "evalue": "Error in .rasterObjectFromFile(x, band = band, objecttype = \"RasterLayer\", : Cannot create a RasterLayer object from this file. (file does not exist)\n", - "output_type": "error", - "traceback": [ - "Error in .rasterObjectFromFile(x, band = band, objecttype = \"RasterLayer\", : Cannot create a RasterLayer object from this file. (file does not exist)\nTraceback:\n", - "1. raster(x = filename)", - "2. raster(x = filename)", - "3. .local(x, ...)", - "4. .rasterObjectFromFile(x, band = band, objecttype = \"RasterLayer\", \n . ...)", - "5. stop(\"Cannot create a RasterLayer object from this file. (file does not exist)\")" - ] - } - ], + "outputs": [], "source": [ "threshold_folder = \"/projects/shared-buckets/tkerr1/data/gfc_threshold\"\n", "\n", @@ -1422,7 +1435,7 @@ }, { "cell_type": "markdown", - "id": "reported-warrior", + "id": "sporting-profit", "metadata": {}, "source": [ "#### Mask to country shape" @@ -1430,8 +1443,8 @@ }, { "cell_type": "code", - "execution_count": 24, - "id": "proper-singles", + "execution_count": 16, + "id": "entertaining-station", "metadata": {}, "outputs": [ { @@ -1456,17 +1469,37 @@ ], "source": [ "cci_masked <- mask(cci_thresholded, aoi, updatevalue=NA)\n", + "\n", + "names(cci_masked) <- c('agbd_2020')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "immune-chicken", + "metadata": {}, + "outputs": [], + "source": [ "jpl_masked <- mask(jpl_thresholded, aoi, updatevalue=NA)\n", + "\n", + "names(jpl_masked) <- c('agbd_2020')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "practical-adoption", + "metadata": {}, + "outputs": [], + "source": [ "nceo_masked <- mask(nceo_thresholded, aoi, updatevalue=NA)\n", "\n", - "names(cci_masked) <- c('agbd_2020')\n", - "names(jpl_masked) <- c('agbd_2020')\n", "names(nceo_masked) <- c('agbd_2020')" ] }, { "cell_type": "markdown", - "id": "executive-struggle", + "id": "julian-bhutan", "metadata": {}, "source": [ "#### Plot forest biomass map and histogram of biomass density for CCI, JPL, and NCEO" @@ -1475,7 +1508,7 @@ { "cell_type": "code", "execution_count": null, - "id": "individual-liverpool", + "id": "informational-gates", "metadata": {}, "outputs": [], "source": [ @@ -1507,7 +1540,7 @@ }, { "cell_type": "markdown", - "id": "tired-cable", + "id": "physical-scientist", "metadata": {}, "source": [ "#### Calculate total aboveground biomass and average aboveground biomass density for 2020 CCI and JPL biomass for the selected country" @@ -1516,7 +1549,7 @@ { "cell_type": "code", "execution_count": null, - "id": "norman-ordinary", + "id": "double-poster", "metadata": {}, "outputs": [], "source": [ @@ -1527,7 +1560,7 @@ }, { "cell_type": "markdown", - "id": "practical-gambling", + "id": "accepted-influence", "metadata": {}, "source": [ "#### Print out basic forest aboveground biomass statistics for the selected country\n" @@ -1536,7 +1569,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dominant-roulette", + "id": "fixed-conference", "metadata": {}, "outputs": [], "source": [ @@ -1560,7 +1593,7 @@ }, { "cell_type": "markdown", - "id": "apparent-aaron", + "id": "needed-cursor", "metadata": {}, "source": [ "## The following is old code I'm keeping here for reference purposes" @@ -1568,7 +1601,7 @@ }, { "cell_type": "markdown", - "id": "constant-fossil", + "id": "secret-aircraft", "metadata": {}, "source": [ "#### Calculate total aboveground biomass and average aboveground biomass density for 2020 CCI and NCEO biomass for the selected country" @@ -1577,7 +1610,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "expected-association", + "id": "naval-disability", "metadata": { "collapsed": true, "jupyter": { @@ -1789,7 +1822,7 @@ }, { "cell_type": "markdown", - "id": "second-dancing", + "id": "adaptive-parcel", "metadata": {}, "source": [ "#### Print out basic forest aboveground biomass statistics for the selected country\n", @@ -1799,7 +1832,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "going-garbage", + "id": "global-preservation", "metadata": {}, "outputs": [ { @@ -1829,7 +1862,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "assigned-graphics", + "id": "floating-discipline", "metadata": {}, "outputs": [ { @@ -1876,7 +1909,7 @@ { "cell_type": "code", "execution_count": null, - "id": "reported-cooperation", + "id": "congressional-equivalent", "metadata": {}, "outputs": [], "source": [] -- GitLab