fao_settings(lang = "zh") # 本文所有图表使用中文fao_data_info()查看你使用的版本和引用格式。
faofishingreport把FAO全球捕捞产量统计(Global Capture Production)整理成报告用的图表、地图和表格。 本文以东北大西洋(FAO主要渔区27)为例,完整演示第一次分析的全过程;下面每张图都由其上方的代码生成。
典型的工作流程:
| 步骤 | 做什么 | 函数 |
|---|---|---|
| 1. 数据 | 检查并下载FAO最新版本,查看所用的版本 |
check_fao_update()、download_fao_data()、fao_data_info()
|
| 2. 渔区 | 某个渔区的总产量、主要物种和主要捕捞国家 |
fishing_area_data()、fishing_area_species()、fishing_area_country()
|
| 3. 物种与国家 | 某个物种由哪些国家捕捞,某个国家捕什么 |
species_country()、country_species()、country_analysis()
|
| 4. 汇总分析 | 类群结构、资源开发状态、趋势、数据质量、多样性、船队 |
species_group_composition()、stock_status()、peak_trend()、data_quality()、coastal_distant()等 |
| 5. 文献方法 | 渔获骤变、渔业崩溃、同步性、中上层/底层比、渔获平均温度 |
catch_shocks()、collapse_analysis()、catch_synchrony()、pelagic_demersal()、mean_temperature_catch()
|
| 6. 资源评估 | 主要物种的CMSY++评估 |
cmsy_setup()、cmsy_area()
|
| 7. 报告 | 一键生成某个渔区的Word报告 | fao_report() |
| 8. 风格 | 语言、主题、颜色、地图投影 | fao_settings() |
📦 安装
faofishingreport需要R 4.2或以上版本,从GitHub安装:
install.packages("remotes")
remotes::install_github("Linbojun99/faofishingreport", dependencies = TRUE)设置dependencies = TRUE后,各项分析用到的包都会随本包一起安装:绘制图表和地图的dplyr、ggplot2和sf,提供世界地图的rnaturalearth,生成Word报告的officer和xml2,输出可编辑PowerPoint图表的eoffice,读取FishBase和SeaLifeBase数据表的nanoparquet,读取海表温度文件的ncdf4,以及CMSY++所需的R包(coda、conicfit、gplots、MASS、mvtnorm、neuralnet等)。唯一的例外是rjags和R2jags,它们需要单独的JAGS程序:第一次使用CMSY++时运行cmsy_setup(),即可安装JAGS和这两个包(见📉 CMSY++资源评估)。
Windows和macOS安装的是二进制包,不需要编译器(Rtools)。在macOS上输出可编辑的PowerPoint图表还需要安装XQuartz。 Linux需要先安装sf包依赖的系统库;如果要绘制中文图表,还需要安装中文字体:
加载本包。启动信息会显示当前操作系统和图表所用的字体(Windows上为SimSun,macOS上为Songti SC,Linux上为Noto Serif CJK SC):
library(faofishingreport)
#> faofishingreport: Windows, chart font "SimSun" (change it with fao_font())💾 获取FAO最新数据
本包自带FAO 2026.1.0版本的数据。FAO大约每年发布一次新版本。可以先检查是否有更新的版本,再下载(约5 MB,几秒钟即可完成):
check_fao_update()
#> FAO Global Capture Production
#> Latest online release: 2026.1.0 (published 2026-03-30)
#> Bundled with package: 2026.1.0
#> Downloaded locally: none
#> Your data is up to date.
download_fao_data() # 只有在有更新版本时才需要运行所有函数都会自动使用可用的最新数据。fao_data_info()显示所用的是哪个版本、来自哪里以及如何引用。这些函数的全部参数、如何选择版本、数据格式以及如何分析自己的数据子集,见💾 FAO数据。
📁 结果保存在哪里
每项分析都会把图表和表格保存在当前工作目录中:
| 文件夹 | 内容 |
|---|---|
figures/png/ |
PNG格式的图表(始终输出);汇总分析的图表在figures/png/summary/
|
figures/pptx/ |
可编辑的PowerPoint图表(设置pptx = TRUE时输出,使用eoffice包) |
tables/ |
CSV格式的表格,用Excel打开时中文名称也能正常显示 |
reports/ |
fao_report()生成的Word报告 |
所以先为报告选定一个文件夹:
setwd("D:/reports/FAO27") # 任意文件夹均可🌊 第一次分析:FAO 27渔区
fishing_area_data()提取某个FAO主要渔区的产量数据,绘制该渔区的总产量并标出平均产量的突变点,计算其占全球所有海洋渔区捕捞产量的比例,并绘制在该渔区捕捞的国家的世界地图。
FAO27 <- fishing_area_data("Atlantic, Northeast")返回结果是一个列表,包括该渔区的产量记录(area_data)、相邻突变点之间的各个时段(coefs_data)和地图数据(act_world_map)。其中FAO27$area_data是其他大多数函数的输入数据:
show_table(FAO27$area_data, n = 5)| Country..Name. | ASFIS.species..Name. | FAO.major.fishing.area..Name. | Unit..Name. | Unit | Year | Production | Production.Type | |
|---|---|---|---|---|---|---|---|---|
| 51634 | Belgium | European eel | Atlantic, Northeast | Tonnes - live weight | TLW, Number | 2018 | 1.0 | actual |
| 51635 | Belgium | European eel | Atlantic, Northeast | Tonnes - live weight | TLW, Number | 2019 | 1.0 | actual |
| 51636 | Belgium | European eel | Atlantic, Northeast | Tonnes - live weight | TLW, Number | 2020 | 0.7 | actual |
| 51637 | Belgium | European eel | Atlantic, Northeast | Tonnes - live weight | TLW, Number | 2021 | 1.0 | actual |
| 51638 | Belgium | European eel | Atlantic, Northeast | Tonnes - live weight | TLW, Number | 2022 | 0.0 | actual |
其他渔区的用法完全相同。全部FAO主要渔区的名称如下:
data <- load_fao_data()
sort(unique(data$FAO.major.fishing.area..Name.))
#> [1] "Africa - Inland waters" "America, North - Inland waters"
#> [3] "America, South - Inland waters" "Arctic Sea"
#> [5] "Asia - Inland waters" "Atlantic, Antarctic"
#> [7] "Atlantic, Eastern Central" "Atlantic, Northeast"
#> [9] "Atlantic, Northwest" "Atlantic, Southeast"
#> [11] "Atlantic, Southwest" "Atlantic, Western Central"
#> [13] "Europe - Inland waters" "Former USSR area - Inland waters"
#> [15] "Indian Ocean, Antarctic" "Indian Ocean, Eastern"
#> [17] "Indian Ocean, Western" "Mediterranean and Black Sea"
#> [19] "Oceania - Inland waters" "Pacific, Antarctic"
#> [21] "Pacific, Eastern Central" "Pacific, Northeast"
#> [23] "Pacific, Northwest" "Pacific, Southeast"
#> [25] "Pacific, Southwest" "Pacific, Western Central"🐟 主要物种和国家
27渔区产量最高的十个物种、它们的产量变化以及平均产量的突变点:
species <- fishing_area_species(FAO27$area_data, rank_range = 1:10)主要捕捞国家的分析方法相同:
countries <- fishing_area_country(FAO27$area_data, rank_range = 1:10)rank_range列出要显示的名次:1:10为前十名,11:20为其后十名,c(5, 6)为第五和第六名。
🖥️ 控制台中显示的结果
函数运行结束时,会在控制台显示结果摘要:分析的对象、主要结果表的前几行、保存的图表和表格,以及返回结果包含的部分。结果本身以不可见的方式返回,赋值(species <- ...)即可保存。下面是第五和第六名物种:
fao_settings(show_data = TRUE) # 默认设置(本网站的文章关闭了摘要)
species56 <- fishing_area_species(FAO27$area_data, rank_range = c(5, 6))
#>
#> ── fishing_area_species(): Atlantic, Northeast ─────────────────────────────────
#> Ranks 5 to 6 of 1029 species items, by catch over all years (catch_t and share_pct: all years):
#> rank species catch_t share_pct
#> 5 大西洋鲭 44,615,940 6.19
#> 6 Sandeels(=Sandlances) nei 33,532,765 4.65
#> Charts saved in figures/png/area/: area_species.png, area_species_wrap.png
#> Tables saved in tables/: species_ranked_table.csv, species_coefs_data.csv
#> Results returned: $area_species, $area_species_ranked, $area_species_ranked_total, $coefs_data
fao_settings(show_data = FALSE)plot_show = TRUE会在保存每张图的同时,把图画在绘图窗口中(RStudio的Plots窗格);无论是否显示,plot = TRUE都会保存图片文件:
species <- fishing_area_species(FAO27$area_data, rank_range = 1:10, plot_show = TRUE)
fao_settings(plot_show = TRUE) # 本次会话的所有函数都显示图
fao_settings(show_data = FALSE) # 不在控制台显示摘要🌐 中文与中英双语图表
每项分析都有一个lang参数,取值为"en"(英文)、"zh"(中文)或"both"(中英双语)。国家、物种和渔区名称使用FAO官方中文名。
species_country(FAO27$area_data, species_name = "Atlantic cod", lang = "both")如果希望所有图表都使用中文,只需用fao_settings(lang = "zh")设置一次即可。本文开头就是这样设置的,所以本文其余的图表都是中文。
📊 第一项汇总分析:资源开发状态
stock_status()根据每个物种的产量相对于其历史峰值产量的比例,判断其资源开发状态(资源状态图,Kleisner等2013):
status <- stock_status(FAO27$area_data)📝 一键生成Word报告
fao_report()运行某个渔区的各项分析,并生成一份Word报告,包括封面、摘要、数据来源与分析方法、附图表的结果、结论、参考文献和附表。渔区可以用名称或代码指定:
fao_report(27, lang = "en") # 在工作目录中生成reports/FAO27_report_en.docx报告默认包括总产量及其阶段、主要物种和主要国家、ISSCAAP类群、资源状态图、数据质量、渔获多样性,以及沿岸国与远洋捕捞;渔获骤变、渔业崩溃、同步性、中上层/底层比、渔获平均温度、远洋国家概况和CMSY++可以另外打开。把lang设为"zh"即生成中文报告。全部设置见📝 一键生成评估报告(Word、LaTeX、PDF)。
⚙️ 本文所用函数的设置
各分析函数共有的参数:
| 参数 | 含义 | 默认值 |
|---|---|---|
lang |
图表文字和名称的语言:"en"、"zh"或"both"
|
NULL:使用fao_settings()中的语言(默认"en") |
plot |
是否保存图表 | TRUE |
table |
是否在tables/中保存表格(fishing_area_data()没有此参数) |
TRUE |
pptx |
同时保存可编辑的PowerPoint图表 |
FALSE,或fao_settings()中的pptx
|
plot_show |
保存图表的同时把图画在绘图窗口中(例如RStudio的Plots窗格) |
FALSE,或fao_settings()中的plot_show
|
ZH |
指定中文的旧方式:ZH = TRUE等同于lang = "zh"(只有渔区、物种和国家分析函数有此参数) |
FALSE |
label |
汇总分析(如stock_status())输出文件名中使用的名称 |
NULL:数据所属的渔区(或国家) |
每个函数还有各自的参数,各篇文章中都有完整的参数表:
| 函数 | 主要参数 | 全部参数 |
|---|---|---|
check_fao_update()、download_fao_data()、load_fao_data()、fao_data_info()
|
version、data_dir、overwrite、quiet
|
💾 FAO数据 |
fishing_area_data() |
area_name、timeseries_analysis、data_version、颜色和文字大小 |
🌊 渔区分析 |
fishing_area_species()、fishing_area_country()
|
rank_range、timeseries_analysis、h_value、线条和文字样式 |
🌊 渔区分析 |
species_country() |
species_name、rank_range、h_value、地图样式 |
🐟 物种与国家分析 |
stock_status() |
taxon_levels、min_years、min_consecutive、min_catch、smooth
|
📈 类群结构、资源状态与趋势 |
fao_report() |
area、lang、file、各部分的开关、各项分析的设置 |
📝 一键生成评估报告(Word、LaTeX、PDF) |
fao_settings()、fao_font()
|
lang、theme、palette、map_projection、dpi等 |
🎨 自定义图表与地图 |
🧭 下一步
- 🎓 教程:东北太平洋(FAO 67区)从零到报告:一个完整的示例,涵盖本包的全部分析,并讲解每张图怎么看
- 💾 FAO数据:下载与自定义:版本、数据格式、数据子集、中文名称
- 🌊 渔区分析:渔区分析函数的全部选项
-
🐟
物种与国家分析:
species_country()、country_species()、country_analysis() - 📈 类群结构、资源状态与趋势和🔍 数据质量、多样性与船队:各项汇总分析
- 🔬 渔获骤变、渔业崩溃、同步性与远洋捕捞:来自文献的方法(渔获骤变、渔业崩溃、同步性与组合效应、远洋船队,以及FAO数据版本之间的修订)
- 🌡️ 海表温度与渔获平均温度:渔区海表温度(内置或读取自己的NetCDF文件)与渔获平均温度
- 🐠 FishBase与SeaLifeBase物种特征:将FAO物种条目与FishBase和SeaLifeBase匹配,并使用其物种特征
- 📉 CMSY++资源评估:主要物种的仅基于渔获量的资源评估
- 📝 一键生成评估报告(Word、LaTeX、PDF):把某个渔区的全部分析写成一份Word报告
- 🧩 扩展(不纳入Word报告):🚢 贸易与就业:进出口与渔获的对比、渔业与养殖从业人数、人均渔获
- 🎨 自定义图表与地图:主题、色板、地图投影、字体和输出设置
📖 参考文献
Bai, J. and Perron, P. (2003). Computation and analysis of multiple structural change models. Journal of Applied Econometrics 18(1): 1–22. doi:10.1002/jae.659
CWP (Coordinating Working Party on Fishery Statistics). CWP Handbook of Fishery Statistics: Main water areas (FAO major fishing areas). Rome: FAO. https://www.fao.org/cwp-on-fishery-statistics/handbook/general-concepts/main-water-areas/en/
FAO (2026). FishStat: Global capture production 1950–2024 (release 2026.1.0). In: FishStatJ. https://www.fao.org/fishery/statistics/software/fishstatj/en. Licence: CC-BY-4.0. Release file: https://www.fao.org/fishery/static/Data/Capture_2026.1.0.zip
FAO (2026). Fishery and Aquaculture Statistics – Yearbook 2024. FAO Yearbook of Fishery and Aquaculture Statistics. Rome: FAO. doi:10.4060/ce1217en
Kleisner, K., Zeller, D., Froese, R. and Pauly, D. (2013). Using global catch data for inferences on the world’s marine fisheries. Fish and Fisheries 14(3): 293–311. doi:10.1111/j.1467-2979.2012.00469.x
Natural Earth. Free vector and raster map data at 1:10m, 1:50m and 1:110m scales. https://www.naturalearthdata.com/
Zeileis, A., Kleiber, C., Krämer, W. and Hornik, K. (2003). Testing and dating of structural changes in practice. Computational Statistics & Data Analysis 44(1–2): 109–123. doi:10.1016/S0167-9473(03)00030-6
Zeileis, A., Leisch, F., Hornik, K. and Kleiber, C. (2002). strucchange: an R package for testing for structural change in linear regression models. Journal of Statistical Software 7(2): 1–38. doi:10.18637/jss.v007.i02
