diff --git a/app/assets/scripts/components/common/layers/index.js b/app/assets/scripts/components/common/layers/index.js index e9bb68c6..206b2103 100644 --- a/app/assets/scripts/components/common/layers/index.js +++ b/app/assets/scripts/components/common/layers/index.js @@ -8,10 +8,12 @@ import population from './layer-population'; import nightlightsViirs from './layer-nightlights-viirs'; import nightlightsHd from './layer-nightlights-hd'; import detectionShip from './layer-detection-ship'; +import recovery from './layer-recovery'; import slowdown from './layer-slowdown'; import waterChlorophyll from './layer-water-chlorophyll'; import waterSpm from './layer-water-spm'; import agriculture from './layer-agriculture'; +import detectionPlane from './layer-detection-plane'; import agTogo from './layer-togo-ag'; const layers = [ @@ -23,29 +25,36 @@ const layers = [ nightlightsViirs, nightlightsHd, detectionShip, + recovery, slowdown, waterChlorophyll, waterSpm, agriculture, + detectionPlane, agTogo ]; export default layers; const layersBySpotlight = { - be: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown'], - du: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown'], - gh: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown'], - la: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'detection-ship'], - sf: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'detection-ship', 'water-chlorophyll', 'water-spm'], - tk: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs'], - ny: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'detection-ship', 'water-chlorophyll', 'water-spm'], + be: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'recovery', 'detection-plane'], + du: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'recovery'], + gh: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'recovery'], + la: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'detection-ship', 'detection-plane', 'recovery'], + sf: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'recovery', 'detection-ship', 'detection-plane', 'water-chlorophyll', 'water-spm'], + tk: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'recovery', 'detection-plane'], + ny: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'detection-ship', 'detection-plane', 'water-chlorophyll', 'water-spm', 'recovery'], togo: ['togo-ag'] }; const layerOverridesBySpotlight = { be: { - 'nightlights-viirs': handleNightlightsViirs + 'nightlights-viirs': handleNightlightsViirs, + 'detection-plane': (l, spotlightId) => + handleInferenceTimeseries(l, spotlightId, { + domain: ['2020-01-09', '2020-01-12', '2020-01-14', '2020-02-10', '2020-02-18', '2020-03-12', '2020-03-13', '2020-03-19', '2020-04-11', '2020-05-05', '2020-05-14'] + }) + }, du: { 'nightlights-viirs': handleNightlightsViirs @@ -62,6 +71,10 @@ const layerOverridesBySpotlight = { 'detection-ship': (l, spotlightId) => handleInferenceTimeseries(l, spotlightId, { domain: ['2020-01-22', '2020-02-02', '2020-02-03', '2020-02-27', '2020-02-29', '2020-03-03', '2020-03-08', '2020-03-15', '2020-03-21', '2020-03-22', '2020-03-27', '2020-04-23', '2020-04-24'] + }), + 'detection-plane': (l, spotlightId) => + handleInferenceTimeseries(l, spotlightId, { + domain: ['2020-01-10', '2020-01-14', '2020-02-01', '2020-02-03', '2020-03-22', '2020-04-15', '2020-04-21', '2020-05-04', '2020-05-05'] }) }, sf: { @@ -81,7 +94,11 @@ const layerOverridesBySpotlight = { ...l, domain: ['2020-03-02', '2020-04-03', '2020-04-19', '2020-05-04', '2020-05-05', '2020-05-21', '2020-05-24', '2020-05-28', '2020-06-01', '2020-06-03', '2020-06-06', '2020-06-13', '2020-06-21', '2020-06-22', '2020-06-23', '2020-06-25', '2020-06-28', '2020-07-01', '2020-07-03'] }; - } + }, + 'detection-plane': (l, spotlightId) => + handleInferenceTimeseries(l, spotlightId, { + domain: ['2020-01-11', '2020-01-12', '2020-01-13', '2020-02-06', '2020-02-07', '2020-02-10', '2020-02-15', '2020-02-18', '2020-02-20', '2020-03-09', '2020-03-10', '2020-03-12', '2020-03-19', '2020-04-02', '2020-04-03', '2020-04-07', '2020-04-15', '2020-04-22', '2020-05-04', '2020-05-05', '2020-05-07', '2020-05-19'] + }) }, tk: { 'nightlights-viirs': handleNightlightsViirs, @@ -94,7 +111,11 @@ const layerOverridesBySpotlight = { tiles: l.source.tiles.map(t => t.replace('&rescale=-100%2C100', '')) } }; - } + }, + 'detection-plane': (l, spotlightId) => + handleInferenceTimeseries(l, spotlightId, { + domain: ['2020-01-19', '2020-02-01', '2020-02-05', '2020-03-18', '2020-03-19', '2020-04-09', '2020-04-10', '2020-05-02'] + }) }, ny: { 'nightlights-viirs': handleNightlightsViirs, @@ -120,7 +141,11 @@ const layerOverridesBySpotlight = { // For NY, nightlights goes till June domain: [l.domain[0], '2020-06-01'] }; - } + }, + 'detection-plane': (l, spotlightId) => + handleInferenceTimeseries(l, spotlightId, { + domain: ['2020-01-16', '2020-01-20', '2020-02-17', '2020-02-19', '2020-03-09', '2020-03-15', '2020-04-06', '2020-04-15', '2020-05-05', '2020-05-14'] + }) } }; diff --git a/app/assets/scripts/components/common/layers/layer-co2-diff.js b/app/assets/scripts/components/common/layers/layer-co2-diff.js index d0f974cc..12af9275 100644 --- a/app/assets/scripts/components/common/layers/layer-co2-diff.js +++ b/app/assets/scripts/components/common/layers/layer-co2-diff.js @@ -9,12 +9,12 @@ export default { timeUnit: 'day', domain: [ '2020-01-01', - '2020-05-17' + '2020-07-16' ], source: { type: 'raster', tiles: [ - `${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2/xco2_15day_diff.{date}.tif&resampling_method=bilinear&bidx=1&rescale=-0.000001%2C0.000001&color_map=rdbu_r` + `${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2-diff/xco2_16day_diff.{date}.tif&resampling_method=bilinear&bidx=1&rescale=-0.000001%2C0.000001&color_map=rdbu_r` ] }, exclusiveWith: ['agriculture', 'no2', 'no2-diff', 'co2', 'gibs-population', 'car-count', 'nightlights-viirs', 'nightlights-hd', 'detection-ship', 'detection-multi', 'water-chlorophyll', 'water-spm'], diff --git a/app/assets/scripts/components/common/layers/layer-co2.js b/app/assets/scripts/components/common/layers/layer-co2.js index 8b1c0924..88894101 100644 --- a/app/assets/scripts/components/common/layers/layer-co2.js +++ b/app/assets/scripts/components/common/layers/layer-co2.js @@ -11,12 +11,12 @@ export default { timeUnit: 'day', domain: [ '2020-01-01', - '2020-05-17' + '2020-07-16' ], source: { type: 'raster', tiles: [ - `${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2/xco2_15day_mean.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}` + `${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2-mean/xco2_16day_mean.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}` ] }, @@ -30,7 +30,7 @@ export default { source: { type: 'raster', tiles: [ - `${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2/xco2_15day_base.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}` + `${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2-base/xco2_16day_base.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}` ] } }, diff --git a/app/assets/scripts/components/common/layers/layer-detection-plane.js b/app/assets/scripts/components/common/layers/layer-detection-plane.js new file mode 100644 index 00000000..72c04e85 --- /dev/null +++ b/app/assets/scripts/components/common/layers/layer-detection-plane.js @@ -0,0 +1,29 @@ +import config from '../../../config'; +import { indicatorGroupColors } from '../../../styles/theme/theme'; + +export default { + id: 'detection-plane', + name: 'Planes', + type: 'inference-timeseries', + domain: [ + '2020-01-01', + '2020-04-30' + ], + source: { + vector: { + type: 'geojson', + data: `${config.api}/detections/plane/{spotlightId}/{date}.geojson` + }, + raster: { + type: 'raster', + tiles: [ + `${config.api}/planet/{z}/{x}/{y}?date={date}&site={spotlightId}` + ] + } + }, + exclusiveWith: ['agriculture', 'no2', 'no2-diff', 'co2-diff', 'co2', 'gibs-population', 'car-count', 'nightlights-viirs', 'nightlights-hd', 'detection-multi', 'water-chlorophyll', 'water-spm'], + enabled: false, + swatch: indicatorGroupColors.economic, + timeUnit: 'day', + info: 'Planes detected each day in PlanetScope imagery are shown in red.' +}; diff --git a/app/assets/scripts/components/common/layers/layer-recovery.js b/app/assets/scripts/components/common/layers/layer-recovery.js new file mode 100644 index 00000000..bb223e86 --- /dev/null +++ b/app/assets/scripts/components/common/layers/layer-recovery.js @@ -0,0 +1,22 @@ +import config from '../../../config'; + +import { indicatorGroupColors } from '../../../styles/theme/theme.js'; + +export default { + id: 'recovery', + name: 'Recovery Proxy Map', + type: 'raster', + source: { + type: 'raster', + tiles: [ + `${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/rpm/rpm-{spotlightId}.cog.tif&resampling_method=bilinear&bidx=1%2C2%2C3%24` + ] + }, + paint: { + 'raster-opacity': 0.9 + }, + exclusiveWith: ['agriculture', 'co2', 'co2-diff', 'gibs-population', 'car-count', 'nightlights-viirs', 'nightlights-hd', 'detection-ship', 'detection-multi', 'water-chlorophyll', 'water-spm'], + enabled: true, + swatch: indicatorGroupColors.economic, + info: 'Recovery Proxy Maps show areas with the greatest increase in car activity shaded in orange. Darker orange indicates areas of greater change.' +}; diff --git a/app/assets/scripts/components/common/layers/types.js b/app/assets/scripts/components/common/layers/types.js index 667cb6f9..3e2e5fa1 100644 --- a/app/assets/scripts/components/common/layers/types.js +++ b/app/assets/scripts/components/common/layers/types.js @@ -214,6 +214,16 @@ export const layerTypes = { const vectorData = vector.data.replace('{date}', formatDate); const rasterTiles = raster.tiles.map(tile => tile.replace('{date}', formatDate)); + // inference data moves around, recenter on each update + fetch(vectorData) + .then(res => res.json()) + .then(geo => { + mbMap.fitBounds(bbox(geo)); + }) + .catch(err => { + console.log(err); // eslint-disable-line no-console + }); + replaceVectorData(mbMap, vecId, vectorData); replaceRasterTiles(mbMap, rastId, rasterTiles); }, @@ -262,7 +272,7 @@ export const layerTypes = { mbMap.fitBounds(bbox(geo)); }) .catch(err => { - throw err; + console.log(err); // eslint-disable-line no-console }); } } diff --git a/package.json b/package.json index c0e428e8..11530529 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "covid-dashboard", - "version": "1.5.0", + "version": "1.6.0", "description": "Frontend application for the Covid Dashboard", "repository": { "type": "git",