Skip to content

Commit

Permalink
Merge pull request #213 from unepwcmc/chore/update-statistics-2022-04
Browse files Browse the repository at this point in the history
Chore/update statistics 2022 04
  • Loading branch information
defaye authored Apr 4, 2022
2 parents 3161c3b + c0e4829 commit 44adfce
Show file tree
Hide file tree
Showing 9 changed files with 678 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ yarn-debug.log*
previous_failed_specs.txt
coverage
/TAGS

.directory
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1.4.3

* Update docs to correct path to country habitat stats (again).
* Update global and country habitat stats for 2022-04 period.
## 1.4.2

* Update docs to correct path to country habitat stats.
* Update global and country habitat stats for 2022-01 period.

## 1.4.1

* Do not automatically update the Redlist species timestamp.
Expand Down
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,41 @@ To lint your factories, run `rake factory_bot:lint`

## Statistics updates

### High level update overview

1. Pull latest from `main` and ensure `develop` up to date with `main`.
2. Checkout your stats update branch e.g. `git checkout -b chore/update-statistics-2022-01` from `develop`.
3. Pull in *country* stats to `lib/data/habitat_coverage_protection/country/*.csv`.
4. Check CSV formatting is correct, especially headers.
5. Update `habitats.yml` with `total_area` and `protected_area` from *global* stats.
6. Check whether you need to do anything else with O+ team.
7. Check the documentation is still relevant, and update if neccessary.
8. Commit everything and push to GitHub. Then create a PR and review it yourself for any mistakes.
9. Merge your update into develop.
10. Pull down your merge from develop and return to develop branch.
11. Checkout a release branch e.g. `git checkout -b release-1.4.2`
12. Update the `CHANGELOG.md` following previous examples of format.
13. Commit and push to GitHub.
14. Return to `main` and merge release into main e.g. `git merge --no-ff release-1.4.2`.
15. Push to GitHub.
16. Go to GitHub releases and [draft a new release ](https://github.com/unepwcmc/ocean-plus-habitats/releases/new).
17. Come back to terminal and deploy with pre-deploy task for habitat stats refresh e.g. `bundle exec cap production deploy TASK=import:refresh`.
18. That's it, you're done. But [go and check everything is working](http://ocean-plus-habitats.web-supported-production.linode.unep-wcmc.org/).

### Low-level overview

The current procedure for updating statistics is as follows:

* Obtain the global and country statistics from the Ocean Plus Habitats team.
* Ensure the country statistics CSVs conform to the format: `<habitat-type><plural-modifier>_country_output_<YYYY>-<MM>-01.csv`.
I.e. ensure that the match the current format within `lib/data/countries/habitat_coverage_protection/country/*.csv`.
I.e. ensure that the match the current format within `lib/data/habitat_coverage_protection/country/*.csv`.

:sos:

###### If received over Slack, you can quickly save to the simplest location on disk possible (as there is currently no "download all") and then move all by command line e.g. `mv ~/Desktop/*country*01-01.csv lib/data/habitat_coverage_protection/country/`.

* In each CSV, check that the columns are correct and that the data format appears to be the same according to previous months.
Most commonly, you will need to rename `"iso_ter"` to `"iso3"` as the ISO column in each CSV.
Most commonly, you will need to rename `"iso3"` to `"iso3"` as the ISO column in each CSV.

As of writing, the global statistics needs to be copied in from each CSV provided into the corresponding habitat within `config/habitats.yml`.
Previously, this data would have been calculated automatically based on the country statistics. But due to inaccuracies
Expand Down
12 changes: 6 additions & 6 deletions config/habitats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ habitats:
point_table: 'wcmc008_coralreef2010_pt_v4'
wms_url: 'https://gis.unep-wcmc.org/arcgis/rest/services/marine/WCMC_008_CoralReefs_WMS/MapServer/export?transparent=true&format=png32&bbox={bbox-epsg-3857}&bboxSR=EPSG:3857&imageSR=EPSG:3857&size=256,256&f=image'
total_area: 149886.974126351
protected_area: 67459.5970010873
protected_area: 67459.5970006499
saltmarshes:
name: 'saltmarshes'
title: 'Saltmarshes'
Expand All @@ -16,16 +16,16 @@ habitats:
point_table: 'wcmc027_saltmarshes_pt_v6'
wms_url: 'https://gis.unep-wcmc.org/arcgis/rest/services/marine/WCMC_027_Saltmarsh_WMS/MapServer/export?transparent=true&format=png32&bbox={bbox-epsg-3857}&bboxSR=EPSG:3857&imageSR=EPSG:3857&size=256,256&f=image'
total_area: 224435.075089817
protected_area: 111626.044395594
protected_area: 111625.448046161
mangroves:
name: 'mangroves'
title: 'Mangroves'
theme: 'yellow'
poly_table: 'wcmc011_atlasmangrove2010_py_v3'
point_table:
wms_url: 'https://gis.unep-wcmc.org/arcgis/rest/services/marine/WCMC_011_WorldAtlasMangroves_WMS/MapServer/export?transparent=true&format=png32&bbox={bbox-epsg-3857}&bboxSR=EPSG:3857&imageSR=EPSG:3857&size=256,256&f=image'
total_area: 135869.552269998
protected_area: 58078.5089440701
total_area: 135869.552269959
protected_area: 58091.716936663
seagrasses:
name: 'seagrasses'
title: 'Seagrasses'
Expand All @@ -34,7 +34,7 @@ habitats:
point_table: 'wcmc_013_014_seagrassespt_v6'
wms_url: 'https://gis.unep-wcmc.org/arcgis/rest/services/marine/WCMC_013_014_Seagrass_WMS/MapServer/export?transparent=true&format=png32&bbox={bbox-epsg-3857}&bboxSR=EPSG:3857&imageSR=EPSG:3857&size=256,256&f=image'
total_area: 314001.940552758
protected_area: 83662.3936917851
protected_area: 83662.3936871938
coldcorals:
name: 'coldcorals'
title: 'Cold-water corals'
Expand All @@ -43,5 +43,5 @@ habitats:
point_table: 'wcmc001_coldcorals2017_pt_v5'
wms_url: 'https://gis.unep-wcmc.org/arcgis/rest/services/marine/WCMC_001_ColdCorals2017_WMS/MapServer/export?transparent=true&format=png32&bbox={bbox-epsg-3857}&bboxSR=EPSG:3857&imageSR=EPSG:3857&size=256,256&f=image'
total_area: 15336.9752787556
protected_area: 4513.803239803
protected_area: 4513.80323972863

Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
"iso3","total_area","protected_area","percent_protected"
"ABNJ",1874.98221419641,421.629372626203,22.4871131807994
"ABW",3.54881962864481,0,0
"AGO",3.39567053773998,0,0
"AIA",3.38364589335382,0,0
"ALB",5.98647948252716,0,0
"ARG",61.8263440651753,6.98422602063557,11.2965211290401
"ASM",0.998440794849897,0,0
"ATA",18.8890674198804,5.41915114173775,28.6893525301
"ATF",14.3193147158519,14.3193147158519,100
"ATG",0.997746538545076,0,0
"AUS",333.428727950404,122.414638995168,36.7138847776118
"BEN",0.997746527205306,0,0
"BES",9.6108429947203,9.6108429947203,100
"BHS",412.761934786788,32.6122202202251,7.9009757130514
"BLM",0.997746564489533,0.997746564489533,100
"BLZ",2.99323973953098,1.99549312134955,66.6666653858546
"BMU",26.3981335788759,0,0
"BRA",233.165254915499,1.99549316229226,0.855827838935714
"BRB",6.37970478883903,0,0
"CAN",204.280433116829,22.9600988252007,11.239499777284
"CHL",86.8581116896839,46.2352596925966,53.2307907611213
"CHN",0.997746571639701,0,0
"CIV",9.97746576754958,0,0
"COK",2.3826012700284,2.3826012700284,100
"COL",56.1477557221478,10.89431447625,19.4029384365094
"CPV",34.3151290222723,0,0
"CRI",8.97971910900959,2.99323973787266,33.3333337216468
"CUB",56.277985296135,0,0
"CUW",4.9887328907093,0,0
"CYM",1.99549313274619,0,0
"CYP",0.998101946907064,0,0
"DMA",7.3651650429386,0,0
"DNK",2.99365873047323,0,0
"DOM",20.0701086865526,17.4317996988043,86.8545356233371
"DPT",229.89902396618,185.243639172674,80.5760877001048
"DZA",2.5290385636979,0,0
"ECU",52.6278347129635,50.6323415510359,96.208293248599
"ERI",2.74578579390164,0,0
"ESP",1469.083604719,1257.62536792682,85.6061128098542
"FJI",2.99323971956311,0,0
"FRA",239.896192978977,178.912849137112,74.579278193377
"FRO",287.549263288492,0,0
"FSM",1.99549317053256,0,0
"GBR",352.975252551642,202.820857977171,57.4603620256628
"GHA",7.61553161242364,0,0
"GIN",0.998146567593262,0.998146567593262,100
"GLP",9.19477485048201,9.16986702835446,99.7291089501093
"GNB",0.997746560532099,0,0
"GNQ",4.39760340599616,3.26008430454921,74.1332040107132
"GRC",17.0600645525478,0.997746578259555,5.84843378046038
"GRD",14.9650777683986,0.278272351153,1.85947814945955
"GRL",18.3319350570199,0,0
"GTM",0.997746563836964,0,0
"GUF",5.98647933098521,0,0
"GUY",15.4553640726882,0,0
"HMD",1.99549314057558,0.997746560926959,49.9999995309014
"HND",12.3844405176936,0.997746580674196,8.05645260477223
"HRV",72.3828884378215,0.997746571876348,1.37842878808772
"HTI",3.99098626516811,0,0
"IDN",144.255161624918,3.9909863193429,2.76661595632881
"IND",10.9752122615403,0,0
"IRL",474.374394242633,187.917398643326,39.6137314585345
"ISL",528.361101493694,316.867529204908,59.9717746649238
"ITA",166.128989497245,48.9377945872373,29.4577091784748
"JAM",19.5994634664317,0.997746576420656,5.09068311043061
"JPN",95.2004617816563,9.59890596500837,10.0828355087432
"KEN",3.99098631850294,0,0
"KIR",1.99549316032311,0,0
"KNA",6.51111490902298,0,0
"LBR",6.93362618358551,0,0
"LCA",12.3844174162346,1.76116507923105,14.220814916351
"LKA",3.99098634737099,0,0
"MAR",152.069298267823,0,0
"MDG",9.37406314085495,0.997746585254377,10.6436938845217
"MEX",117.738383967179,45.9973331205691,39.0674065421106
"MHL",8.97971910029726,0,0
"MLT",4.34711451271544,3.33789040240339,76.78404589159
"MMR",5.98647941695625,0,0
"MNE",1.99549313801732,0,0
"MOZ",11.9729587680157,0,0
"MRT",39.6204336641054,0,0
"MSR",6.96977023996479,0,0
"MTQ",6.54682430758551,6.54682430758551,100
"MUS",0.997746579673261,0,0
"MYS",7.47166374201478,0.100966641788051,1.35132743220621
"NAM",1.99549315598508,0,0
"NCL",69.5987054118583,61.6450588823612,88.5721343774565
"NFK",41.7871319935976,41.6953290439574,99.7803080870582
"NGA",9.19148440299485,0,0
"NIC",5.49799999620016,0.422557530579863,7.68565898275566
"NOR",3017.02068872933,239.127829342362,7.92595921651018
"NZL",831.974151997951,236.767279429134,28.4584898293472
"OMN",4.98873283503172,0,0
"PAN",32.9256369568588,0.121064862520771,0.367691785824518
"PER",8.97971908075518,0.997746571348176,11.1111111870581
"PHL",174.352255369976,112.645239820787,64.6078478203528
"PLW",3.24242093570336,3.24242093570336,100
"PNG",1.99549314958219,0,0
"PRI",33.814589651525,6.47154170631325,19.1383121102621
"PRT",369.793066177503,105.470581781425,28.5215141732263
"RUS",17.9482763207811,0,0
"SAU",6.9842260911645,0,0
"SEN",4.19373899705194,0,0
"SGS",1.24353842074005,0.16011082865611,12.8754227441421
"SHN",14.3647412205723,8.28364217293744,57.6664907897826
"SJM",2.99323969393461,0,0
"SOM",8.97971912156534,0,0
"SPM",2.9932397982855,0,0
"STP",0.997746554697471,0,0
"SUR",34.4225685734462,0,0
"SWE",31.0529245436098,19.3690018739923,62.3741633313508
"SYC",3.44559793005424,0,0
"TCA",2.99323972468268,0,0
"THA",3.99098637555205,0,0
"TLS",6.03496586934398,0,0
"TON",1.99549321591097,0,0
"TTO",14.0099836042785,0,0
"TUN",11.2526376432774,0,0
"TUV",0.997746564827538,0,0
"TWN",4.12520435586714,0,0
"UMI",9.38785685362166,9.38785685362166,100
"URY",22.2218651326868,0,0
"USA",2137.24104821964,399.877658988042,18.7099933964467
"VCT",10.272776718187,0,0
"VEN",68.0550161904896,1.99549307838309,2.93217633333243
"VGB",7.98201000193008,0,0
"VIR",7.98197261387586,0.0425599107840693,0.533200411012225
"VNM",1.31862966938088,0,0
"VUT",18.1009321578198,0,0
"WLF",33.1123345937815,0,0
"WSM",1.99549315802455,0,0
"YEM",0.997746569395683,0,0
"ZAF",44.6205635802445,25.219753111022,56.5204719247157
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
"iso3","total_area","protected_area","percent_protected"
"ABW",66.5257434761535,0.494249113192906,0.742944140669502
"AIA",24.3337905218337,11.061888498537,45.4589616385972
"ARE",126.761555170089,59.9976094380869,47.3310771215939
"ASM",45.1590904217466,12.8077880948817,28.3614837572416
"ATF",137.509204423328,43.6709723592565,31.7585812109082
"ATG",54.8946288086163,34.0320862195155,61.9952934524148
"AUS",31683.868469488,27425.2835412991,86.5591383442021
"BES",200.532585281889,197.646076492077,98.5605786781464
"BGD",4.53097443625609,0,0
"BHR",207.846294391492,0.0000125028931051369,0.00000601545153438572
"BHS",2226.52344364776,365.619343884382,16.4210866464258
"BLM",10.7130787461384,10.6083367829893,99.0222982054825
"BLZ",894.571592598028,368.999393410442,41.2487269284718
"BMU",528.915295492159,0.0782259351129308,0.0147898795477527
"BRA",697.508463347012,570.816769287793,81.836536656303
"BRB",31.2227004063655,0.284625165569483,0.911596889010456
"BRN",62.736094142188,0,0
"CCK",115.152796279885,7.11853317765398,6.18181529899805
"CHN",568.75681592756,0.00000313751090256278,0.000000551643657658142
"COK",253.267917975378,110.19062107485,43.5075322432122
"COL",934.807894159329,831.509304825238,88.9497521384341
"COM",218.976991976775,130.270773249896,59.4906213999475
"CPT",3.8410151537575,3.75888871633021,97.8618559380858
"CRI",69.8620497617106,24.5026517879331,35.0729070668669
"CUB",2649.28141294029,741.759521405158,27.9985175520452
"CUW",38.6732272155731,5.55119799671472,14.354111090267
"CXR",5.03441231725536,0.669976659443783,13.3079417660618
"CYM",136.703454098431,51.3959800696223,37.5966945448325
"DJI",247.190961159525,0,0
"DMA",16.3589633919245,0.727007963536417,4.44409554639202
"DOM",350.604976049933,229.384886688664,65.4254509656461
"DPT",1959.22408113993,1183.76610138235,60.4201486076877
"ECU",125.413568309819,125.413568309819,100
"EGY",2207.10880252002,1157.47481502015,52.4430337869421
"ERI",1583.18776808474,0,0
"FJI",3366.66410826214,1172.48940960061,34.8264445723349
"FSM",3171.83567924391,55.6613510936497,1.75486238010029
"GLP",113.331772065992,111.921964355132,98.7560348831049
"GRD",45.4431923245749,2.99456602496455,6.58969115456516
"GTM",7.06314739238198,5.08667552604251,72.0171227281593
"GUM",136.868368586213,9.50686020793446,6.94598781744526
"HND",717.914337311414,243.944372280304,33.979593330574
"HTI",325.602719796727,114.121495993399,35.0493067332622
"IDN",20103.4759073885,6788.41910559341,33.7673899621433
"IND",2036.5686996224,0,0
"IRN",117.604362425968,1.72289630901478,1.46499353720773
"ISR",0.793356959935676,0.605763184239616,76.3544299515227
"JAM",412.681124524885,72.331114739451,17.5271197156703
"JOR",2.86070435046009,0.319393218706919,11.1648454219168
"JPN",1038.59789808939,769.884722575549,74.1273137555768
"KEN",410.17083033528,124.792828045584,30.4245984395273
"KHM",47.4636924358226,8.03641425423907,16.9317089375324
"KIR",1960.04450246774,72.8100194054221,3.71471256462557
"KNA",41.8207486356309,41.1408408655975,98.3742333836316
"KWT",72.7455221277148,0,0
"LCA",29.4758166276421,3.74404106316117,12.7020774706885
"LKA",108.902758257978,0.989204930757828,0.908337811255904
"MAF",6.20538653993903,6.18148620175662,99.6148452956383
"MDG",2401.19262887085,818.073432929061,34.0694629449099
"MDV",2696.11221556477,119.539344364491,4.43376739567384
"MEX",1560.48415487727,1089.46073446789,69.8155589124565
"MHL",1992.45189889416,358.465514295139,17.9911753199208
"MMR",605.711660810521,38.0741145358433,6.28584803615884
"MNP",81.4012004309254,11.153187890086,13.7015029643822
"MOZ",1675.05525056339,162.539866054386,9.70355252459389
"MSR",2.42337577584969,0,0
"MTQ",72.0061818384689,71.8421960550745,99.7722615208757
"MUS",2551.10918368508,1839.17136891162,72.0930088243002
"MYS",2148.12186462979,669.353382267632,31.1599352573505
"MYT",166.236988064711,165.091853870517,99.3111435622568
"NCL",4574.81550404733,3618.3734443886,79.0933195270373
"NIC",460.096382117654,280.52987262467,60.9719796824948
"NIU",15.3818564031818,0.379728862595909,2.46868032468019
"NRU",5.91543097709155,0,0
"OMN",266.191499792615,46.4368681546685,17.4449102209675
"PAN",630.693599060019,68.3134740214335,10.8314836432853
"PCN",39.4042857499816,35.3632698545728,89.7447299995518
"PHL",13485.4703070914,6299.95124492235,46.7165853430377
"PLW",506.399384829981,506.253254880009,99.9711433397532
"PNG",7255.24898314781,297.170348345126,4.09593590840757
"PRI",158.139999715516,33.6710879388224,21.2919489056498
"PYF",3000.33979819576,0.318502673071748,0.0106155533870956
"QAT",155.314399820548,0.567754192429643,0.365551547754512
"REU",12.1231525821093,10.1486278470807,83.7127783251484
"SAU",3419.26971724347,438.95143793615,12.8375786128396
"SDN",613.065587203154,121.622739084942,19.8384547467088
"SGP",3.85049928877091,0,0
"SLB",2804.80799679427,145.125246825435,5.17415976392341
"SOM",398.799681938048,0,0
"SXM",1.70293351871973,0.0192108490204567,1.12810328819527
"SYC",1493.61105483546,1402.49118106227,93.899357300671
"TCA",191.625656606749,16.9497448753368,8.84523772832819
"THA",183.931960517407,116.01121873255,63.0728984817031
"TKL",96.5721017293588,0,0
"TLS",35.0497470582209,9.55487220220462,27.2608877500117
"TON",992.045050511086,164.60043727206,16.5920325077233
"TTO",32.025848022524,4.99522785364437,15.5974881605982
"TUV",885.565367715921,66.2450348595456,7.48053585591394
"TWN",375.201257705391,193.245426175168,51.5044718551836
"TZA",1814.32607411626,833.504853153585,45.9401904125517
"UMI",172.330311243945,172.330311243945,100
"USA",4089.96838696817,3573.66325857874,87.3763051559388
"VCT",38.7063756302732,18.7420668764878,48.421136237383
"VEN",344.413780196915,186.450531328625,54.1356188541653
"VGB",137.132429967879,0.576480826087225,0.420382564665599
"VIR",33.5206997104829,11.6844457275109,34.8574040173059
"VNM",478.142638619609,105.454052995411,22.0549360123698
"VUT",706.934537986607,2.40955292919088,0.34084526921735
"WLF",411.163036132112,0,0
"WSM",199.995942811373,20.0732116749996,10.0368094436454
"YEM",652.240702383273,1.65589449712139,0.253877823182575
"ZAF",1.39881332507099,1.39881332507099,100
Loading

0 comments on commit 44adfce

Please sign in to comment.