Skip to content

Commit

Permalink
chore: ee layer refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
turban committed Nov 5, 2023
1 parent a53f87e commit 2154093
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 74 deletions.
67 changes: 0 additions & 67 deletions src/components/earthEngine/layers/earthEngine_OLD.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
},
]
*/

Expand Down
12 changes: 8 additions & 4 deletions src/components/earthEngine/layers/index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/components/earthEngine/layers/landcover_CGLS.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
42 changes: 42 additions & 0 deletions src/components/earthEngine/layers/legacy/nighttime_DMSP-OLS .js
Original file line number Diff line number Diff line change
@@ -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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
'#6baed6',
'#3182bd',
'#08519c',
], // Blues
], // Blues (ColorBrewer)
},
opacity: 0.9,
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default {
'#cb181d',
'#a50f15',
'#67000d',
], // Reds
], // Reds (ColorBrewer)
},
opacity: 0.9,
}
23 changes: 23 additions & 0 deletions src/components/earthEngine/layers/testing/rivers.js
Original file line number Diff line number Diff line change
@@ -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,
}

0 comments on commit 2154093

Please sign in to comment.