Skip to content

Commit 2e82c0c

Browse files
authored
Merge pull request #3327 from Vizzuality/bugfix/fao-widget
Updates FAO extent query to include countries with no primary forest
2 parents 15fda98 + c2a8178 commit 2e82c0c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

app/javascript/pages/country/widget/widgets/widget-fao-cover/widget-fao-cover-selectors.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const getFAOCoverData = createSelector(
2222
} = data;
2323
const colorRange = getColorPalette(colors.ramp, 3);
2424
const naturallyRegenerated = extent / 100 * forest_regenerated;
25-
const primaryForest = extent / 100 * forest_primary;
25+
const primaryForest = forest_primary ? extent / 100 * forest_primary : 0;
2626
const plantedForest = extent / 100 * forest_planted;
2727
const nonForest =
2828
area_ha - (naturallyRegenerated + primaryForest + plantedForest);
@@ -64,15 +64,18 @@ export const getSentence = createSelector(
6464
const { area_ha, extent, forest_primary } = data;
6565
const primaryForest = extent / 100 * forest_primary;
6666
const sentence = `FAO data from 2015 shows that <strong>${locationNames.current &&
67-
locationNames.current.label}</strong> contains ${
67+
locationNames.current.label}</strong> contains <strong>${format('.3s')(
68+
extent
69+
)}Ha</strong> of forest, ${
6870
primaryForest > 0
69-
? ` <strong>${format('.3s')(
70-
extent
71-
)}Ha</strong> of forest, with Primary forest occupying
71+
? ` with Primary forest occupying
7272
<strong>${format('.1f')(
7373
primaryForest / area_ha * 100
7474
)}%</strong> of the country.`
75-
: ''
75+
: ` which occupies
76+
<strong>${format('.1f')(
77+
extent / area_ha * 100
78+
)}%</strong> of the country.`
7679
}`;
7780
return sentence;
7881
}

app/javascript/services/forest-data.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const SQL_QUERIES = {
2424
locationsLoss:
2525
"SELECT {select} AS region, year_data.year as year, SUM(year_data.area_loss) as area_loss, FROM data WHERE polyname = '{indicator}' AND iso = '{iso}' {region} AND thresh= {threshold} GROUP BY {group}, nested(year_data.year) ORDER BY {order}",
2626
fao:
27-
"SELECT fao.iso, fao.name, forest_planted, forest_primary, forest_regenerated, fao.forest_primary, fao.extent, a.land as area_ha FROM gfw2_countries as fao INNER JOIN umd_nat_staging as a ON fao.iso = a.iso WHERE fao.forest_primary is not null AND fao.iso = '{country}' AND a.year = 2001 AND a.thresh = 30",
27+
"SELECT fao.iso, fao.name, forest_planted, forest_primary, forest_regenerated, fao.forest_primary, fao.extent, a.land as area_ha FROM gfw2_countries as fao INNER JOIN umd_nat_staging as a ON fao.iso = a.iso WHERE fao.iso = '{country}' AND a.year = 2001 AND a.thresh = 30",
2828
faoExtent:
2929
'SELECT country AS iso, name, year, reforest AS rate, forest*1000 AS extent FROM table_1_forest_area_and_characteristics as fao WHERE fao.year = {period} AND reforest > 0 ORDER BY rate DESC',
3030
faoDeforest:

0 commit comments

Comments
 (0)