This script calculates mean annual net primary production values globally from 2003 to 2015. This data is used to standardize commercial fishing catch to produce fishing pressure layers for OHI and Cumulative Human Impacts.
Reference: Behrenfeld, M.J. and Falkowski, P.G., 1997. Photosynthetic rates derived from satelliteābased chlorophyll concentration. Limnology and oceanography, 42(1), pp.1-20.
Downloaded: July 30, 2016
Description: Monthly Net Primary Production (mg C / m2 / day)
Native data resolution: 0.083 x 0.083 degree grid
Time range: 2002 - 2015, monthly. Only partial data provided for 2002. OHI uses 2003 - 2015.
Format: XYZ format
library(fields)
library(raster)
library(doParallel)
library(foreach)
library(parallel)
library(RColorBrewer)
source("~/github/ohiprep/src/R/common.R")
source('vgpm_func.R')
cols = rev(colorRampPalette(brewer.pal(11, 'Spectral'))(255)) # rainbow color scheme
#paths
dir_git <- file.path(dir_M,'git-annex/globalprep/prs_fish/v2016/VGPM_primary_productivity')
#unzip all files
tars <- list.files(file.path(dir_M,'git-annex/globalprep/_raw_data/VGPM_primary_productivity/d2016'),full.names=T, pattern = '.tar')
lapply(tars,untar, exdir = file.path(dir_M,'git-annex/globalprep/_raw_data/VGPM_primary_productivity/d2016'))
This code sources a function, vgpm.raster
that transforms the raw .xyz files into GeoTIFFs.
files = list.files(file.path(dir_M,'git-annex/globalprep/_raw_data/VGPM_primary_productivity/d2016'), full.names=TRUE, pattern = '.gz')
registerDoParallel(12)
foreach (file = files) %dopar%{
print(file)
vgpm.raster(file, w.lon, e.lon, n.lat, s.lat, log = TRUE,
color = tim.colors(30))
}
Calculate the mean annual Net Primary Production per year and save as rasters.
#global ocean raster at 1km
ocean = raster(file.path(dir_M,'model/GL-NCEAS-Halpern2008/tmp/ocean.tif'))
# set mollweide projection
moll_crs = CRS("+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs")
registerDoParallel(7)
foreach (i = 2004:2015) %dopar%{
print(i)
l = list.files(file.path(dir_git,'int/rasterized_rawdata'),pattern=as.character(i),full.names=T)%>%
stack()%>%
calc(fun=function(x){mean(x,na.rm=T)})%>%
projectRaster(.,crs=moll_crs, over = T,filename = paste0(file.path(dir_git,'int/annual_npp/annual_mean_npp_'),i,'.tif',sep=''),overwrite=T)
out = raster::resample(l,ocean,method='ngb',
filename=paste0(file.path(dir_git,'int/annual_npp/annual_mean_npp_moll_1km_'),i,'.tif',sep=''),overwrite=T)
}
raster(file.path(dir_M,'git-annex/globalprep/prs_fish/v2016/VGPM_primary_productivity/int/annual_npp/annual_mean_npp_moll_1km_2015.tif'))%>%plot(col=cols,box=F,axes=F,main = 'Mean Net Primary Productivity (mg C/m2/day)')
Behrenfeld, M.J. and Falkowski, P.G., 1997. Photosynthetic rates derived from satelliteābased chlorophyll concentration. Limnology and oceanography, 42(1), pp.1-20.
Downloaded from http://www.science.oregonstate.edu/ocean.productivity/standard.product.php