Creating Spatial Indicator Time Series with EDAB_Utilities
Source:vignettes/create-spatial-indicator-time-series.Rmd
create-spatial-indicator-time-series.Rmd
Creating Spatial Indicators
The function NEesp::create_spatial_indicator generates a spatially-aggregated time series from a netCDF file. The function passes data through EDABUtilities::make_2d_summary_ts, which provides summary statistics of 2d gridded data as time series by area and outputs as a data frame.
This function has been tested with GLORYS bottom temperature and salinity data, OCCCI chlorophyll and mean primary production data, and OISST sea surface temperature data. All test input files can be found in ‘data-raw’ in this package.
GLORYS Bottom Temperature
Setting file.time = annual and agg.time = days returns a daily value for a netCDF on a daily time step.
glorys_bt <- create_spatial_indicator(indicator_name = "bottomT",
units = "degC",
data.in = c(here::here('data-raw','glorys_bottomT.nc')),
file.time = 'annual',
output.files = c(here::here('data-raw','GLORYS_monthly_bottomT.nc')),
shp.file = here::here('data-raw/shapefiles','EPU_NOESTUARIES.shp'),
var.name = 'bottomT',
area.names = c('MAB','GB'),
statistic = 'mean',
agg.time = 'days',
tz = NA,
touches = TRUE,
write.out = F)
head(glorys_bt)
GLORYS Bottom Salinity
Setting file.time = annual and agg.time = days returns a daily value for a netCDF on a daily time step.
glorys_sal <- create_spatial_indicator(indicator_name = 'bottomS',
units = '1e-3',
data.in = c(here::here('data-raw','glorys_bottomS.nc')),
output.files = c(here::here('data-raw','GLORYS_daily_bottomS.nc')),
file.time = 'annual',
shp.file = here::here('data-raw/shapefiles','EPU_NOESTUARIES.shp'),
var.name = 'bottomS',
area.names = c('MAB','GB'),
statistic = 'mean',
agg.time = 'days',
tz = NA,
touches = TRUE,
write.out = F)
head(glorys_sal)
OCCCI Chlorophyll-a
Setting file.time = annual and agg.time = days returns a monthly value for a netCDF on a monthly time step.
occci_chl <- create_spatial_indicator(indicator_name = 'chlor_a',
units = 'milligram m-3',
data.in = c(here::here('data-raw','occci_test2.nc')),
output.files = c(here::here('data-raw','occci_chl.nc')),
file.time = 'annual',
shp.file = here::here('data-raw/shapefiles','EPU_NOESTUARIES.shp'),
var.name = 'bottomS',
area.names = c('MAB','GB'),
statistic = 'mean',
agg.time = 'days',
tz = NA,
touches = TRUE,
write.out = F)
head(occci_chl)
OCCCI Primary Production
Setting file.time = annual and agg.time = days returns a monthly value for a netCDF on a monthly time step.
occci_primprod <- create_spatial_indicator(indicator_name = "primary_production_mean",
units = 'gCarbon/m^2/day',
data.in = c(here::here('data-raw','pp_occci_199798.nc')),
file.time = 'annual',
output.files = c(here::here('data-raw','OCCCI_PRIM_PROD.nc')),
shp.file = here::here('data-raw/shapefiles','EPU_NOESTUARIES.shp'),
var.name = 'primary productivity',
area.names = c('MAB','GB'),
statistic = 'mean',
agg.time = 'days',
tz = NA,
touches = TRUE,
write.out = F)
head(occci_primprod)
OISST Sea Surface Temperature
OISST data is formatting using a 0-360 longitude. It must be passed through EDABUtilities::convert_longitude to convert to -180 to +180 longitude before running ‘create_spatial_indicator’
sst_monthly_converted <- EDABUtilities::convert_longitude(data = here::here('data-raw/sst_monthly.nc'))
sst_monthly <- NEesp2::create_spatial_indicator(indicator_name = 'sst',
units = 'degC',
data.in = sst_monthly_converted,
output.files = c(here::here('data-raw','sst_monthly_test.nc')),
file.time = 'annual',
shp.file = here::here('data-raw/shapefiles','EPU_NOESTUARIES.shp'),
var.name = 'sst',
area.names = c('MAB','GB'),
statistic = 'mean',
agg.time = 'days',
tz = NA,
touches = TRUE,
write.out = F)
head(sst_monthly)