WHRC Data Analysis (Global) - wri/gfw-analysis GitHub Wiki

Blue Raster Approach for WHRC Data Analysis

Last updated: 7/08/2015


Biomass Loss Analysis Workflow Simplified

Step One - WHRC Data Preparation

  • Download Tiffs using FTP (ftp://[email protected])
  • Create a new Mosaic dataset, add Tiffs folder as the Workspace
    • Create new file geodatabase to hold the mosaic layer
    • Inside the file geodatabase, right click and select New-->Mosaic Dataset
    • Set the Coordinate System to WGS84
    • When the mosaic completes, right click and select Add Rasters
      • For Input Data select "Workspace" and navigate to the folder containing the WHRC tiffs
      • Leave all other defaults

Step Two - Country Boundary Data Preparation

  • Dissolve the GADM countries layer on the first three fields (ID_0, ISO, NAME_0)
  • Project the GADM dissolved layer to WGS84
  • Select by Attributes where the projected/dissolved GADM layer intersects the footprints of the Biomass Mosaic
  • Export only the selected features to a new layer (147 of the 253 countries intersected in this analysis)
  • Create a new geodatabase that will host polygon layers for each of the 147 individual countries
    • Use the Split GP tool to create a feature class for every country in the projected/dissolved GADM layer

Step Three - Running the Model

  • There are two Models from ModelBuilder that were created to help automate this analysis; they can both be found here: Models

NOTE: This Model will fail if it is unable to build a raster attribute table for a country polygon raster after the Extract by Mask GP. Countries that cause the Model to fail are: Argentina, Australia, Brazil, Dem Rep of Congo, China, Guam, India, Indonesia, N Mariana Islands, United States. Guam and N Mariana Islands fail because they are completely out of the Loss Year mosaic boundary. The others have an extent to large and a workaround is described below. For now, do not run the Model with the aforementioned countries.

  • Run the Model called "Biomass_Analysis_2015" to generate the Biomass Analysis Results. Note you will have to change some input and output parameter paths. This Model takes the individual country polygons created in Step Two and:
    • Extracts the Loss Year data by the Country Mask
    • Builds a raster attribute table on the Country Loss Year raster
    • Runs the Zonal Statistics as Table GP tool to create a table for each country that SUMs the values of the loss data within both Biomass and Area mosaics. SUM fields include:
      • Pixel Count (COUNT)
      • Area m2 (AREA)
      • Total of pixel values (SUM)
  • For the tables that did generate, run the Model called “Add_ISO_Field” which will iterate through a workspace of tables and all a field for all tables created called “ISO.” This is necessary because when all tables are merged, there will need to be a field with a Unique Identifier
  • After the ISO field is added to the tables, they need to be populated with the ISO name
  • Run this python script, which will take the first three letters of the table name and populate the ISO field with it
    • (ex. file name "abc_tbl" would translate to "abc" in the ISO field)
    • Note you will need to update the directory of the tables based on where they are saved on your machine
  • Merge all Biomass results tables into one, and merge all Area results tables into one

For the countries that were left out of the analysis so far because they fail to build a raster attribute table:

  • Create a fishnet grid for each of the countries:
    • Set the Template Extent to the country polygon
    • Set Number of Rows to 5
    • Set Number of Columns to 5
    • Uncheck "Create Label Points"
    • Change "Geometry Type" to POLYGON
  • Use the Union GP tool with the country polygon and the grid as the inputs
  • In the resulting layer of the Union, delete the grid attributes (leaving the country chopped into grids)
  • Make sure all of the grid areas contain data from the Loss Year mosaic (select by location with the Loss Year footprints)
  • Create a new text field called "Split_ID" in all of the new country grid layers
    • Concatenate the "ISO" field and the "OBJECTID" field to get a unique identifier
  • Run the Split GP tool to create a new layer for each unique value in each country grid layer
  • Run the Model "Biomass_Analysis_2015" on the grids and it should no longer fail to Build Raster Attribute Table
  • Run the tool "Add_ISO_Field" to create the ISO fields
  • Run the Python code referenced above in the python window of ArcMap
  • Since this troubleshoot results in multiple tables per country, use the Merge GP tool to combine them all into one table
  • Use the Summary Statistics GP tool to consolidate all values for a country
    • Statistical Field(s)
    • COUNT (Field) - SUM (Statistical Type)
    • AREA (Field) - SUM (Statistical Type)
    • SUM (Field) - SUM (Statistical Type)
  • Case fields: VALUE & ISO
  • The Summary Statistics output table will need to be added to the existing merged tables, but a few changes are needed first. In the Summary Statistics output table:
    • Create new fields for "COUNT," "AREA," and "SUM" and use the field calculator to populate the values from the existing "SUM_COUNT," "SUM_AREA," and "SUM_SUM" respectively
      • COUNT: Long, Precision 10
      • AREA: Double
      • SUM: Double
    • Delete the "FREQUENCY" field
    • Delete the "SUM_COUNT," "SUM_AREA," and "SUM_SUM" fields
  • Merge the new Summary Statistic output tables with the original merge for the tables that ran correctly

Step Four- Compile Results in Spreadsheet

  • With all country tables generated and merged (one for Biomass and one for Hansen Area), open the merged DBFs in Excel*
  • Open a blank Excel file and enter the following fields in at the top (note that not all of these fields may be relevant to every analysis, but keep them in for consistency):*
  • YEAR
  • ISO
  • CODE
  • PIXEL COUNT BIOMASS
  • BIOMASS SUM
  • AREA M2 (Equal Area) SUM
  • EQUAL AREA HA
  • PIXEL COUNT AREA
  • Equal Area HA Pixel Size
  • Mg of Biomass to Tg C
  • Total
  • Description
  • Map the fields from the merged Biomass and Hansen Area to the new Excel sheet
    • In the merged Biomass DBF:
      • VALUE --> YEAR
        • Delete zero (0) value and change 1 - 13 to 2001 - 2013
      • COUNT --> PIXEL COUNT BIOMASS
      • SUM --> BIOMASS SUM
    • In the merged Area DBF:
      • COUNT --> PIXEL COUNT AREA
      • SUM --> AREA M2 (Equal Area) SUM
    • The remaining fields are calculations
      • EQUAL AREA HA = AREA M2 (Equal Area) SUM / 10,000
      • Equal Area HA Pixel Size = EQUAL AREA HA / PIXEL COUNT AREA
      • Mg of Biomass to Tg C = BIOMASS SUM / 1,000,000
      • Total = Equal Area HA Pixel Size * Mg of Biomass to Tg C

File locations for data referenced in this analysis:

  • Server: GFW-Analysis
  • GADM2 Countries Feature Class: D:\GIS Data\GADM\gadm2.gdb
  • WHRC Tiffs: ftp://[email protected]
  • Biomass Mosaic: J:\WHRC Carbon Tiffs\mosaics.gdb
  • Loss Mosaic: J:\Database\GFW2013.gdb
  • Area Mosaic: J:\hansen_area\hansen_area.gdb