Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new lakes data #1173

Merged
merged 3 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions data/downloads/process-lakes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

FOLDER=./download/lakes

set -e

for filename in $FOLDER/*.tif; do
TIF_FILENAME=$filename
NC_FILENAME=${filename%.*}.nc
echo $TIF_FILENAME
python ./data/tif2netcdf.py -v lswt -f $TIF_FILENAME -o $NC_FILENAME
done
18 changes: 13 additions & 5 deletions data/gdal-colors/colors-lswt.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
3500 230 56 30
2250 230 230 30
1250 30 230 30
500 20 210 230
-500 28 88 203
3500 120 10 10
3000 240 40 40
2500 240 120 30
2000 250 210 35
1500 148 200 148
1000 100 200 200
500 65 168 240
0 40 40 140
-500 10 10 60
-4999 10 10 60
-5000 255 255 255
-42767 0 0 0 0
nv 0 0 0 0

1 change: 1 addition & 0 deletions data/layers-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
},
"lakes.lswt": {
"colorMap": "custom",
"basemap": "dark",
"timeFormat": {
"year": "numeric",
"month": "long"
Expand Down
6 changes: 4 additions & 2 deletions data/tif2netcdf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pip install rioxarray

from datetime import time
import xarray as xr
import rasterio
import rioxarray
import pandas as pd
import re
from argparse import ArgumentParser
Expand All @@ -11,7 +13,7 @@
parser.add_argument("-v", "--variable", dest="variable")
args = parser.parse_args()

da = xr.open_rasterio(args.file)
da = rioxarray.open_rasterio(args.file)
ds = da.to_dataset(name=args.variable)

timestamp = re.search("(\d+).tif$", args.file).group(0)
Expand Down
10 changes: 5 additions & 5 deletions data/triggers/lakes_lswt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ TIMEOUT=16000
LAYER_ID="lakes.lswt"
VARIABLE_ID="lswt"
LAYER_TYPE="image"
VERSION="1.7.1"
VERSION="1.8.1"
LON_RES="4320"
LAT_RES="2160"
ZOOM_LEVELS="0-3"
MIN_LON="-180"
MAX_LON="180"
MAX_LON="360"
MIN_LAT="-90"
MAX_LAT="90"
MIN="-500"
MAX="3500"
MAX_LAT="180"
MIN="auto"
MAX="auto"
MACHINE_TYPE="N1_HIGHCPU_8"

if [ ! -f ./package.json ]; then
Expand Down
9 changes: 8 additions & 1 deletion scripts/generate-legend-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ files.forEach(file => {
function readColorFile(file) {
const filePath = path.join(INTPUT_FOLDER, file);
const content = fs.readFileSync(filePath, 'utf8');
return content
const stops = content
.split('\n')
.filter(Boolean)
.filter(line => !line.startsWith('nv'))
.map(line => line.split(' '));

if (file.includes('lswt')) {
// do not include the "ice" color
return stops.filter(([v]) => v > -1000);
}

return stops;
}

function writeImage(file, canvas) {
Expand Down