View source: R/Get_Belanger_PP.R
Get_Belanger_PP | R Documentation |
Download Arctic primary production data from Belanger et al. (2013) and then convert to a raster object.
Get_Belanger_PP(url, x, outdir = NULL, plot = FALSE)
url |
A character string naming the URL of a txt file to be downloaded |
x |
Raster* object defining the spatial extent, resolution and projection of climatology data to be retrived. If not provide, returning full data set. |
outdir |
output directory to write raster file |
plot |
Logical, whether or not to plot the output raster |
This function dowloads primary production data from Belanger et al (2013). The units of the variables: Chla : mg m^-3, KPUR : m^-1, PAR : E m^-2 month^-1, PP : mg C m^-2 month^-1
a raster object
Chih-Lin Wei <chihlinwei@gmail.com>
# Raster template of Canadian Arctic
data(tmp)
# Download August 2010 as example
Get_Belanger_PP(url = "ftp://ftparcticnetl:nord.a13@ftp.uqar.ca/Arcticnet/donnees_pour_VRoy/Monthly_PAR_CHL_KPUR_PP_201008_52.0_-140.0_80.0_-50.0.txt",
x = tmp, plot = TRUE)
# Use foreach loop to download monthly data from 1998 to 2010
library(RCurl)
library(foreach)
library(doSNOW)
# UQAR FTP server
# Embed the User ID and Password in the URL
User <- "ftparcticnetl"
Pass <- "nord.a13"
url <- paste("ftp://", User, ":", Pass, "@ftp.uqar.ca/Arcticnet/donnees_pour_VRoy/", sep="")
filenames = getURL(url, ftp.use.epsv = FALSE, ftplistonly = TRUE, crlf = TRUE)
filenames = paste(url, strsplit(filenames, "\r*\n")[[1]], sep = "")
# Create a folder to save raster file
folder <- "../Arctic_ocean_data/Productivity_Belanger_2013/"
dir.create(folder)
cl<-makeCluster(4) # change 4 to your number of CPU cores
registerDoSNOW(cl) # register the SNOW parallel backend with the foreach package
foreach(i=filenames, .packages="OceanData") %dopar% Get_Belanger_PP(i, tmp, folder)
stopCluster(cl) # stop a SNOW cluster
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.