This script generates the extent of seagrass for each OHI region.
Creating an actual script to calculate this. This has not been updated since 2012. Updating the data with newest version (version 6).
Downloaded: 07/15/2019
Description:
Global Distribution of Seagrasses https://data.unep-wcmc.org/datasets/7 Reported at spatial cell scale.
This dataset shows the global distribution of seagrasses, and is composed of two subsets of point and polygon occurence data. The data were compiled by UNEP World Conservation Monitoring Centre in collaboration with many collaborators (e.g. Frederick Short of the University of New Hampshire), organisations (e.g. the OSPAR Convention for the Northeast Atlantic sea), and projects (e.g. the European project Mediterranean Sensitive Habitats “Mediseh”), across the globe (full list available in “Metadata_Seagrass.dbf”).
Time range: 1934-2015
Reclassify the seagrass extent data into a mask of 1 or NA, and then compute zonal statistics for the count of cells within an OHI region that have seagrass and then convert into km2.
## This file makes it easier to process data for the OHI global assessment
## by creating the following objects:
##
## * dir_M = identifies correct file path to Mazu (internal server) based on your operating system
## * mollCRS = the crs code for the mollweide coordinate reference system we use in the global assessment
## * regions_shape() = function to load global shapefile for land/eez/high seas/antarctica regions
## * ohi_rasters() = function to load two rasters: global eez regions and ocean region
## * region_data() = function to load 2 dataframes describing global regions
## * rgn_syns() = function to load dataframe of region synonyms (used to convert country names to OHI regions)
## * low_pop() = function to load dataframe of regions with low and no human population
## * UNgeorgn = function to load dataframe of UN geopolitical designations used to gapfill missing data
## loads 2 rasters: zones and ocean
## zones = raster cells with OHI region ID values, see rgns_all.csv to link IDs with names
## ocean = raster with ocean cells identified as 1, otherwise 0
## returns spatial shape object named 'regions'
## which includes land, eez, highseas, and antarctica regions
##
## Reading layer `regions_2017_update' from data source `/home/shares/ohi/git-annex/globalprep/spatial/v2017' using driver `ESRI Shapefile'
## Simple feature collection with 526 features and 7 fields
## geometry type: MULTIPOLYGON
## dimension: XY
## bbox: xmin: -18040060 ymin: -9020048 xmax: 18040080 ymax: 9020048
## epsg (SRID): NA
## proj4string: +proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs
Convert seagrass shapefiles into same CRS as our region zones raster
Fasterize/rasterize: Where there is seagrass assign a value of 1 and NA otherwise
Stack rasters and adjust
Calculate zonal stats with zones raster and new combined seagrass. Convert to km^2 and save int/output files
Data Check
Justification for using ~0.9 km2 for average seagrass polygon area
Explore how gapfilling was done in 2012
## Regions to gapfill as is:
trend <- read_csv(file.path("~/github/ohiprep_v2019/globalprep/hab_seagrass/v2012/data/habitat_trend_seagrass_updated.csv"))
trend_rgns <- c(trend$rgn_id)
zonal_sums_km2_final <- read_csv(file.path(dir_git, 'data/habitat_extent_seagrass_final.csv'))
extent_rgns <- c(zonal_sums_km2_final$rgn_id)
'%!in%' <- function(x,y)!('%in%'(x,y))
extent_trend_rgn_to_gf <- extent_rgns[extent_rgns %!in% trend_rgns]
habitat_health_seagrass_updated <- read_csv(file.path("~/github/ohiprep_v2019/globalprep/hab_seagrass/v2012/data/habitat_health_seagrass_updated.csv"))
health_rgns <- c(habitat_health_seagrass_updated$rgn_id)
extent_health_rgn_to_gf <- extent_rgns[extent_rgns %!in% health_rgns]
extent_health_rgn_to_gf
habitat_health_gf <- read_csv(file.path("~/github/ohiprep_v2019/globalprep/hab_seagrass/v2012/data/health_seagrass_gf.csv"))
habitat_trend_gf <- read_csv(file.path("~/github/ohiprep_v2019/globalprep/hab_seagrass/v2012/data/trend_seagrass_gf.csv"))