From 2154093a9bced0fabea198e817d297679d8b68b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Sun, 5 Nov 2023 18:26:39 +0100 Subject: [PATCH] chore: ee layer refactor --- .../earthEngine/layers/earthEngine_OLD.js | 67 ------------------- src/components/earthEngine/layers/index.js | 12 ++-- .../earthEngine/layers/landcover_CGLS.js | 2 +- .../layers/legacy/nighttime_DMSP-OLS .js | 42 ++++++++++++ .../layers/legacy/precipitation_CHIRPS.js | 2 +- .../layers/legacy/temperature_MOD11A2v061.js | 2 +- ...nd.js => precipitation_daily_ERA5-Land.js} | 0 ....js => precipitation_monthly_ERA5-Land.js} | 0 ...Land.js => temperature_daily_ERA5-Land.js} | 0 ...nd.js => temperature_monthly_ERA5-Land.js} | 0 .../earthEngine/layers/testing/rivers.js | 23 +++++++ 11 files changed, 76 insertions(+), 74 deletions(-) create mode 100644 src/components/earthEngine/layers/legacy/nighttime_DMSP-OLS .js rename src/components/earthEngine/layers/{precipitation_daily_ERA5Land.js => precipitation_daily_ERA5-Land.js} (100%) rename src/components/earthEngine/layers/{precipitation_monthly_ERA5Land.js => precipitation_monthly_ERA5-Land.js} (100%) rename src/components/earthEngine/layers/{temperature_daily_ERA5Land.js => temperature_daily_ERA5-Land.js} (100%) rename src/components/earthEngine/layers/{temperature_monthly_ERA5Land.js => temperature_monthly_ERA5-Land.js} (100%) create mode 100644 src/components/earthEngine/layers/testing/rivers.js diff --git a/src/components/earthEngine/layers/earthEngine_OLD.js b/src/components/earthEngine/layers/earthEngine_OLD.js index 42a717b07..befa9fa34 100644 --- a/src/components/earthEngine/layers/earthEngine_OLD.js +++ b/src/components/earthEngine/layers/earthEngine_OLD.js @@ -2,41 +2,6 @@ import i18n from '@dhis2/d2-i18n' import { EARTH_ENGINE_LAYER } from './layers.js' export const earthEngineLayers = [ - /* - { - layerType: EARTH_ENGINE_LAYER, - layerId: 'WWF/HydroSHEDS/v1/FreeFlowingRivers', - datasetId: 'WWF/HydroSHEDS/v1/FreeFlowingRivers', - format: 'FeatureCollection', - name: 'Rivers', - description: '', - source: 'WWF / Google Earth Engine', - style: { - byProperty: 'COLOR', - }, - opacity: 0.9, - }, - */ - { - layerType: EARTH_ENGINE_LAYER, - layerId: 'WWF/HydroSHEDS/v1/FreeFlowingRivers_FeatureView', - datasetId: 'WWF/HydroSHEDS/v1/FreeFlowingRivers', - format: 'FeatureView', - name: 'Rivers', - description: '', - source: 'WWF / Google Earth Engine', - style: { - lineWidth: 2, - color: { - property: 'RIV_ORD', - mode: 'linear', - palette: ['08519c', '3182bd', '6baed6', 'bdd7e7', 'eff3ff'], - min: 1, - max: 10, - }, - }, - opacity: 0.9, - }, { layerType: EARTH_ENGINE_LAYER, layerId: 'ECMWF/CAMS/NRT/NO2', @@ -287,38 +252,6 @@ export const earthEngineLayers = () => [ }, opacity: 0.9, }, - { - layer: EARTH_ENGINE_LAYER, - legacy: true, // Kept for backward compability - layerId: 'NOAA/DMSP-OLS/NIGHTTIME_LIGHTS', - datasetId: 'NOAA/DMSP-OLS/NIGHTTIME_LIGHTS', - name: i18n.t('Nighttime lights'), - unit: i18n.t('light intensity'), - description: i18n.t( - 'Light intensity from cities, towns, and other sites with persistent lighting, including gas flares.' - ), - source: 'NOAA / Google Earth Engine', - sourceUrl: - 'https://explorer.earthengine.google.com/#detail/NOAA%2FDMSP-OLS%2FNIGHTTIME_LIGHTS', - periodType: 'Yearly', - band: 'stable_lights', - mask: true, - img: 'images/nighttime.png', - params: { - min: 0, - max: 63, - palette: [ - '#ffffd4', - '#fee391', - '#fec44f', - '#fe9929', - '#ec7014', - '#cc4c02', - '#8c2d04', - ], // YlOrBr - }, - opacity: 0.9, - }, ] */ diff --git a/src/components/earthEngine/layers/index.js b/src/components/earthEngine/layers/index.js index f7428b5a1..4b2f467de 100644 --- a/src/components/earthEngine/layers/index.js +++ b/src/components/earthEngine/layers/index.js @@ -1,19 +1,23 @@ import buildings from './buildings_GOOGLE.js' import elevation from './elevation_SRTM.js' import landcover from './landcover_MCD12Q1.js' +import landcover100m from './landcover_CGLS.js' +import nighttimeLights from './legacy/nighttime_DMSP-OLS .js' import populationTotal from './population_total_WorldPop.js' import populationAgeSex from './population_age_sex_WorldPop.js' -import precipitationDaily from './precipitation_daily_ERA5Land.js' -import precipitationMonthly from './precipitation_monthly_ERA5Land.js' +import precipitationDaily from './precipitation_daily_ERA5-Land.js' +import precipitationMonthly from './precipitation_monthly_ERA5-Land.js' import precipitationLegacy from './legacy/precipitation_CHIRPS.js' -import temperatureDaily from './temperature_daily_ERA5Land.js' -import temperatureMonthly from './temperature_monthly_ERA5Land.js' +import temperatureDaily from './temperature_daily_ERA5-Land.js' +import temperatureMonthly from './temperature_monthly_ERA5-Land.js' import temperatureLegacy from './legacy/temperature_MOD11A2v061.js' const earthEngineLayers = [ buildings, elevation, landcover, + landcover100m, + nighttimeLights, populationTotal, populationAgeSex, precipitationDaily, diff --git a/src/components/earthEngine/layers/landcover_CGLS.js b/src/components/earthEngine/layers/landcover_CGLS.js index 994022431..76dc7424e 100644 --- a/src/components/earthEngine/layers/landcover_CGLS.js +++ b/src/components/earthEngine/layers/landcover_CGLS.js @@ -7,7 +7,7 @@ export default { layerId: 'COPERNICUS/Landcover/100m/Proba-V-C3/Global', img: 'images/landcover.png', datasetId: 'COPERNICUS/Landcover/100m/Proba-V-C3/Global', - name: i18n.t('Landcover Copernicus'), + name: i18n.t('Landcover 100m'), description: i18n.t('Distinct landcover types collected from satellites.'), source: 'Copernicus / Google Earth Engine', periodType: 'yearly', diff --git a/src/components/earthEngine/layers/legacy/nighttime_DMSP-OLS .js b/src/components/earthEngine/layers/legacy/nighttime_DMSP-OLS .js new file mode 100644 index 000000000..80768adf1 --- /dev/null +++ b/src/components/earthEngine/layers/legacy/nighttime_DMSP-OLS .js @@ -0,0 +1,42 @@ +import i18n from '@dhis2/d2-i18n' +import { EARTH_ENGINE_LAYER } from '../../../../constants/layers.js' + +export default { + // legacy: true, // Kept for backward compability + layer: EARTH_ENGINE_LAYER, + format: 'ImageCollection', + layerId: 'NOAA/DMSP-OLS/NIGHTTIME_LIGHTS', + datasetId: 'NOAA/DMSP-OLS/NIGHTTIME_LIGHTS', + name: i18n.t('Nighttime lights'), + unit: i18n.t('light intensity'), + description: i18n.t( + 'Light intensity from cities, towns, and other sites with persistent lighting, including gas flares.' + ), + source: 'NOAA / Google Earth Engine', + sourceUrl: + 'https://explorer.earthengine.google.com/#detail/NOAA%2FDMSP-OLS%2FNIGHTTIME_LIGHTS', + periodType: 'yearly', + filters: [ + { + type: 'eq', + arguments: ['system:index', '$1'], + }, + ], + band: 'stable_lights', + mask: true, + img: 'images/nighttime.png', + style: { + min: 0, + max: 63, + palette: [ + '#ffffd4', + '#fee391', + '#fec44f', + '#fe9929', + '#ec7014', + '#cc4c02', + '#8c2d04', + ], // YlOrBr (ColorBrewer) + }, + opacity: 0.9, +} diff --git a/src/components/earthEngine/layers/legacy/precipitation_CHIRPS.js b/src/components/earthEngine/layers/legacy/precipitation_CHIRPS.js index 74148d955..5c488b8b9 100644 --- a/src/components/earthEngine/layers/legacy/precipitation_CHIRPS.js +++ b/src/components/earthEngine/layers/legacy/precipitation_CHIRPS.js @@ -37,7 +37,7 @@ export default { '#6baed6', '#3182bd', '#08519c', - ], // Blues + ], // Blues (ColorBrewer) }, opacity: 0.9, } diff --git a/src/components/earthEngine/layers/legacy/temperature_MOD11A2v061.js b/src/components/earthEngine/layers/legacy/temperature_MOD11A2v061.js index c82beb4df..8d1c77eae 100644 --- a/src/components/earthEngine/layers/legacy/temperature_MOD11A2v061.js +++ b/src/components/earthEngine/layers/legacy/temperature_MOD11A2v061.js @@ -54,7 +54,7 @@ export default { '#cb181d', '#a50f15', '#67000d', - ], // Reds + ], // Reds (ColorBrewer) }, opacity: 0.9, } diff --git a/src/components/earthEngine/layers/precipitation_daily_ERA5Land.js b/src/components/earthEngine/layers/precipitation_daily_ERA5-Land.js similarity index 100% rename from src/components/earthEngine/layers/precipitation_daily_ERA5Land.js rename to src/components/earthEngine/layers/precipitation_daily_ERA5-Land.js diff --git a/src/components/earthEngine/layers/precipitation_monthly_ERA5Land.js b/src/components/earthEngine/layers/precipitation_monthly_ERA5-Land.js similarity index 100% rename from src/components/earthEngine/layers/precipitation_monthly_ERA5Land.js rename to src/components/earthEngine/layers/precipitation_monthly_ERA5-Land.js diff --git a/src/components/earthEngine/layers/temperature_daily_ERA5Land.js b/src/components/earthEngine/layers/temperature_daily_ERA5-Land.js similarity index 100% rename from src/components/earthEngine/layers/temperature_daily_ERA5Land.js rename to src/components/earthEngine/layers/temperature_daily_ERA5-Land.js diff --git a/src/components/earthEngine/layers/temperature_monthly_ERA5Land.js b/src/components/earthEngine/layers/temperature_monthly_ERA5-Land.js similarity index 100% rename from src/components/earthEngine/layers/temperature_monthly_ERA5Land.js rename to src/components/earthEngine/layers/temperature_monthly_ERA5-Land.js diff --git a/src/components/earthEngine/layers/testing/rivers.js b/src/components/earthEngine/layers/testing/rivers.js new file mode 100644 index 000000000..9944685cc --- /dev/null +++ b/src/components/earthEngine/layers/testing/rivers.js @@ -0,0 +1,23 @@ +import i18n from '@dhis2/d2-i18n' +import { EARTH_ENGINE_LAYER } from '../../../constants/layers.js' + +export default { + layerType: EARTH_ENGINE_LAYER, + layerId: 'WWF/HydroSHEDS/v1/FreeFlowingRivers_FeatureView', + datasetId: 'WWF/HydroSHEDS/v1/FreeFlowingRivers', + format: 'FeatureView', + name: i18n.t('Rivers'), + description: '', + source: 'WWF / Google Earth Engine', + style: { + lineWidth: 2, + color: { + property: 'RIV_ORD', + mode: 'linear', + palette: ['08519c', '3182bd', '6baed6', 'bdd7e7', 'eff3ff'], + min: 1, + max: 10, + }, + }, + opacity: 0.9, +}