knitr::opts_chunk$set(echo = TRUE) library(raster) library(rgdal) library(sp) library(maptools) library(rgeos) library(maps) library(dismo) library(gstat) library(proj4) library(ggmap) library(rasterVis) library(viridis) require(plyr) library(dggridR) library(dplyr) #library(gridGraphics) #library(grid) #library(gridExtra) #rm(list=ls())
One of the main intersessional tasks for the SSC for Bottom Fish and Marine Ecosystems in 2019-2020 is to come to consensus on a temporal and spatial scale for sharing data among members. In the discussions during the 2019 NPFC Scientific Committee meetings, a number of ideas were proposed and then these were modified and identified as potential options during intersessional discussions in May-July. There were four main proposals regarding the temporal and spatial resolution for sharing data within the NPFC:
Option 1: A spatial resolution of 0.5 degrees (30") longitude by 0.5 degrees (30") latitude and a temporal resolution 5 years (preferred in preliminary discussions)
Option 2: A spatial resolution 5 nautical mile x 5 nautical mile (8 km x 8 km) and a temporal resolution of the entire time series (1991-present)
Option 3: A spatial resolution of 0.1 degrees longitude by 0.1 degrees latitude and a temporal resolution of 5 years
Option 4: A geodesic hexagonal mesh with resolution level 12 or 13 of ISEA3H grid type (described at https://github.com/r-barnes/dggridR/) and a 5 year temporal resolution
In the intervening month(s), I have written a package for R that will allow each of us to test the output maps and data from each of these options (plus others that you would like to explore). The package can be downloaded at https://github.com/rooperc4/BottomFishingFootprint/ or the code can be run from the example below. The objective of this package is to provide tools that will help us define and map the appropriate temporal and spatial footprint for bottom contacting fishing gear for the NPFC convention area.
To install the package run
#install.packages("devtools") devtools::install_github("rooperc4/BottomFishingFootprint") library(BottomFishingFootprint)
The example below generates random data for the western North Pacific. The data is the positions of sets for three gear types (longline, trap and gillnet). The data were generated for the western North Pacific for 20 years (1991-2020) with a random number of sets (between 10 and 200) and a random number of vessels (between 1 and 10) operating with each gear type in each year.
YearSet<-seq(1991,2020,1) GearSet<-c("Gillnet","Longline","Trap") W_NP<-extent(169,171,42,48) raster1<-raster(W_NP,resolution=.01,crs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",vals=1) effort_data<-array(dim=c(0,5)) colnames(effort_data)<-c("Year","Gear_type","Vessel","Longitude","Latitude") for(i in 1:length(YearSet)){ for(j in 1:length(GearSet)){ sets<-sample(seq(10,200,1),1) sample1<-sampleRandom(raster1,size=sets,xy=TRUE) sample1<-data.frame(Year=rep(YearSet[i],sets),Gear_type=rep(GearSet[j],sets),Vessel=rep(paste0("Vessel_",sample(seq(1,10,1),1)),sets),Longitude=sample1[,1],Latitude=sample1[,2],stringsAsFactors=FALSE) effort_data<-rbind(effort_data,sample1)}}
The example data looks like this (when you use your own data you can copy this format).
head(effort_data)
The package has two main functions. The first is called footprint_data. This function takes a raw fishing effort data frame and summarizes it for mapping, creating a footprint_data_object. The raw fishing effort data should include rows for each individual fishing event (set), such as a trawl haul or longline set. For each set the year, latitude, longitude, gear type and a vessel identifier must be included. A minimum number of vessels can be specified so that the output does not include grid cells where less than this number of vessels fished a given gear type in a given year group. The default value is 3 (consistent with Canadian requirements for confidentiality), The starting year of interest (usually the earliest year in the data) and how many years should be combined should be specified. Additionally, the spatial resolution that is required and the units of that spatial resolution (defaults are 0.5 decimal degrees of latitude and longitude) need to be specified. A map projection (in proj4 format) should also be given.
The function outputs a list of eight data objects that include a data frame of raw fishing effort data (fishing_effort_data) summarized to the spatial resolution provided for each fishing event with an additional column for the year group to which the event belongs. There should be one record in this table for each of the fishing events that were input. This table may not be appropriate to share with the NPFC, as it will contain records for grid cells where fewer than the minimum number of vessels fished. The second data object output by the function (fishing_footprint_table) is a table that summarizes the fishing events by year group, latitude, longitude and gear type. This table produces the number of sets that occurred in each year by each gear type at a grid cell with the spatial resolution specified and the center position given by the latitude and longitude where it was grouped. In addition, a column specifies the number of vessels that are included at each grid cell. The table will not include grid cells where there were fewer than the minimum number of vessels fishing. This table may be appropriate for sharing with the wider group, as it will meet confidentiality rules. The third item is a table of the number of grid cells by gear type and year group where the minimum number of vessels was not met (not_enough_vessels). This table indicates how many grid cells for which data exists, but cannot be reported. The fourth item is the year groups identified from the inputs (years) and the fifth item is the gear types represented in the data (gear_types). The last three items are the spatial resolution and units of the data summary and the map projection of the data (map_projection). These last items are for tracking inputs and outputs and are needed for creating the figures using the footprint_map function.
The second function is called footprint_map. This function takes the fishing effort data object (created by the footprint_data function) and makes a raster map of the effort data. The outputs are a raster stack with layers for each year group and gear type combination and a .png figure for each year group and gear type combination. The .png object is overlaid on a static google map of the eastern or western Pacific, based on the input longitude values of the data. The footprint_data_object must be a list including a data frame of raw fishing effort data (fishing_effort_data), spatially, temporally effort data compiled by gear type (fishing_footprint_table), the number of grid cells where their are not enough vessels represented to plot the data due to confidentiality rules (not_enough_vessels), gear type-year-year groups over which the data is summarized (years), gear types over which the data is summarized (gear_types), the spatial resolution of the data summary, the spatial resolution units (units) and the map projection of the data (map_projection). These 8 items are output from the footprint_data function.
To do option 1, run this code.
#Specify the input spatial resolution and units Spatial_resolution_dd<-data.frame(Spatial_resolution=.5,Units="dd") #Specify the start year and the number of years to combine Start_year<-1991 Years_to_combine<-5 #What is the minimum number of vessels that need to fish a grid cell in order for the data to be shared Minimum_vessels<-3 #Specify the map projection or crs in proj4 format map_projection_dd<-"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" #Call the function example_dd<-footprint_data(effort_data$Year,effort_data$Longitude,effort_data$Latitude,effort_data$Gear_type,effort_data$Vessel,Minimum_vessels,Start_year,Years_to_combine,Spatial_resolution_dd$Spatial_resolution,Spatial_resolution_dd$Units, map_projection=map_projection_dd) #Look at the data head(example_dd$fishing_effort_data) head(example_dd$fishing_footprint_table) example_dd$not_enough_vessels example_dd$years example_dd$spatial_resolution example_dd$units example_dd$map_projection #Make the maps rasters_dd<-footprint_map(example_dd)
To do option 2 run this code.
Spatial_resolution_m<-data.frame(Spatial_resolution=8000,Units="m") Start_year<-1991 Years_to_combine<-29 Minimum_vessels<-3 #map_projection_m<-"+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" #FOR EASTERN NORTH PACIFIC map_projection_m<-"+proj=utm +zone=59 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" #FOR WESTERN NORTH PACIFIC example_m<-footprint_data(effort_data$Year,effort_data$Longitude,effort_data$Latitude,effort_data$Gear_type,effort_data$Vessel,Minimum_vessels,Start_year,Years_to_combine,Spatial_resolution_m$Spatial_resolution,Spatial_resolution_m$Units, map_projection=map_projection_m) #Look at the data head(example_m$fishing_effort_data) head(example_m$fishing_footprint_table) example_m$not_enough_vessels example_m$years example_m$spatial_resolution example_m$units example_m$map_projection rasters_m<-footprint_map(example_m)
To do option 3 run this code.
Spatial_resolution_dd<-data.frame(Spatial_resolution=.1,Units="dd") Start_year<-1991 Years_to_combine<-5 Minimum_vessels<-3 map_projection_dd<-"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" example_dd2<-footprint_data(effort_data$Year,effort_data$Longitude,effort_data$Latitude,effort_data$Gear_type,effort_data$Vessel,Minimum_vessels,Start_year,Years_to_combine,Spatial_resolution_dd$Spatial_resolution,Spatial_resolution_dd$Units, map_projection=map_projection_dd) #Look at the data head(example_dd2$fishing_effort_data) head(example_dd2$fishing_footprint_table) example_dd2$not_enough_vessels example_dd2$years example_dd2$spatial_resolution example_dd2$units example_dd2$map_projection rasters_dd2<-footprint_map(example_dd2)
For Option 4, the spatial resolution is quite small. Thus a five year temporal resolution for this example data takes a really long time (for the actual data, it works fine). In this example I set the years to combine to 30 years. and ran this code. Additionally, although the data are generated on the ISEA 12 and 13 scale, I plotted them using grid cell sizes of 0.08 and 0.05 decimal degrees respectively. This was used for visualization only, the data in the fishing_footprint_object is the actual ISEA 12 and 13 standard.
Spatial_resolution_ISEA12<-data.frame(Spatial_resolution=NA,Units="ISEA_12") Spatial_resolution_ISEA13<-data.frame(Spatial_resolution=NA,Units="ISEA_13") Start_year<-1991 Years_to_combine<-30 Minimum_vessels<-3 map_projection_dd<-"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" example_isea12<-footprint_data(effort_data$Year,effort_data$Longitude,effort_data$Latitude,effort_data$Gear_type,effort_data$Vessel,Minimum_vessels,Start_year,Years_to_combine,Spatial_resolution_ISEA12$Spatial_resolution,Spatial_resolution_ISEA12$Units, map_projection=map_projection_dd) #Look at the data head(example_isea12$fishing_effort_data) head(example_isea12$fishing_footprint_table) example_isea12$not_enough_vessels example_isea12$years example_isea12$spatial_resolution example_isea12$units example_isea12$map_projection rasters_isea12<-footprint_map(example_isea12) example_isea13<-footprint_data(effort_data$Year,effort_data$Longitude,effort_data$Latitude,effort_data$Gear_type,effort_data$Vessel,Minimum_vessels,Start_year,Years_to_combine,Spatial_resolution_ISEA13$Spatial_resolution,Spatial_resolution_ISEA13$Units, map_projection=map_projection_dd) head(example_isea13$fishing_effort_data) head(example_isea13$fishing_footprint_table) example_isea13$not_enough_vessels example_isea13$years example_isea13$spatial_resolution example_isea13$units example_isea13$map_projection rasters_isea13<-footprint_map(example_isea13)
For the sample data, there are a lot of grid cells with not enough vessels for each method. Unsurprisingly, the higher resolution data is better for identifying the spatial extent of the footprint (ISEA and 8 km grids), but either the temporal resolution suffers or a lot of grid cells are missing.
Here's a look at the relationship between resolution and number of cells excluded using the sample data for a number of different combinations of spatial resolution and temporal resolution.
spatialres<-seq(0.05,.5,.05) tempres<-seq(5,30,5) resdata<-data.frame(array(dim=c(0,3))) k<-1 colnames(resdata)<-c("Tres","Spres","GDM") for(i in 1:length(spatialres)){ for(j in 1:length(tempres)){ Spatial_resolution_dd<-data.frame(Spatial_resolution=spatialres[i],Units="dd") #Specify the start year and the number of years to combine Start_year<-1991 Years_to_combine<-tempres[j] #What is the minimum number of vessels that need to fish a grid cell in order for the data to be shared Minimum_vessels<-3 #Specify the map projection or crs in proj4 format map_projection_dd<-"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" #Call the function example_dd<-footprint_data(effort_data$Year,effort_data$Longitude,effort_data$Latitude,effort_data$Gear_type,effort_data$Vessel,Minimum_vessels,Start_year,Years_to_combine,Spatial_resolution_dd$Spatial_resolution,Spatial_resolution_dd$Units, map_projection=map_projection_dd) resdata[k,1]<-tempres[j] resdata[k,2]<-spatialres[i] resdata[k,3]<-sum(example_dd$not_enough_vessels)/(length(example_dd$fishing_footprint_table[,1])+sum(example_dd$not_enough_vessels)) k<-k+1 }} ggplot(resdata)+geom_line(aes(x=Spres,y=GDM,color=as.factor(Tres)))+xlab("Spatial resolution (decimal degrees)")+ ylab("Proportion of cells with less than the minimum vessels")+labs(color="Years aggregated")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.