Last active
August 3, 2018 14:26
-
-
Save thomas-maschler/c9c53de53c78a0de654109890204f9be to your computer and use it in GitHub Desktop.
Restoration potential per Rainfall Classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega/v4.0.json", | |
"width": 240, | |
"height": 75, | |
"padding": 2, | |
"title": { | |
"text": "Average Annual Rainfall", | |
"font": "Fira Sans", | |
"fontSize": 16, | |
"offset": 0, | |
"anchor": "middle" | |
}, | |
"data": [ { | |
"name": "histogram", | |
"format": { | |
"property": "histograms[0].counts" | |
}, | |
"url": "https://production-api.globalforestwatch.org/v1/arcgis-proxy/ImageServer/computeHistograms?server=forest-atlas&service=eth/EthiopiaRestoration&pixelSize=30&renderingRule={\"rasterFunction\":\"Arithmetic\",\"rasterFunctionArguments\":{\"Raster\":\"$5\",\"Raster2\":\"$6\",\"Operation\":3}}&geostore=a3762b2185c422f889c26e0e5e1e90ac", | |
"transform": [ | |
{ | |
"type": "identifier", | |
"as": "id" | |
}, | |
{ | |
"type": "formula", | |
"as": "rounded", | |
"expr": "floor(datum.data*0.09/100)*100" | |
} | |
] | |
}, | |
{ | |
"name": "table", | |
"values": [ | |
{ | |
"id": "1", | |
"label": "No Data", | |
"hex": "#000" | |
}, | |
{ | |
"id": "2", | |
"label": "≤ 400 mm/year", | |
"hex": "#BEFFE8" | |
}, | |
{ | |
"id": "3", | |
"label": "400 - 800 mm/year", | |
"hex": "#00E6A9" | |
}, | |
{ | |
"id": "4", | |
"label": "> 800 mm/year", | |
"hex": "#00614C" | |
} | |
], | |
"transform": [ | |
{ | |
"type": "lookup", | |
"from": "histogram", | |
"key": "id", | |
"fields": [ | |
"id" | |
], | |
"values": [ | |
"rounded" | |
], | |
"as": [ | |
"value" | |
] | |
}, | |
{ | |
"type": "filter", | |
"expr": "datum.value > 0" | |
}, | |
{ | |
"type": "formula", | |
"as": "group", | |
"expr": "1" | |
}, | |
{ | |
"type": "stack", | |
"groupby": [ | |
"group" | |
], | |
"sort": { | |
"field": "id" | |
}, | |
"field": "value" | |
}] | |
} | |
], | |
"scales": [ | |
{ | |
"name": "y", | |
"type": "band", | |
"range": "height", | |
"padding": 0.15, | |
"domain": { | |
"data": "table", | |
"field": "group" | |
} | |
}, | |
{ | |
"name": "x", | |
"type": "linear", | |
"range": "width", | |
"nice": true, | |
"zero": true, | |
"domain": { | |
"data": "table", | |
"field": "y1" | |
} | |
}, | |
{ | |
"name": "color", | |
"type": "ordinal", | |
"domain": { | |
"data": "table", | |
"field": "label" | |
}, | |
"range":{"data": "table", "field": "hex"} | |
}, | |
{ | |
"name": "colorStroke", | |
"type": "ordinal", | |
"domain": { | |
"data": "table", | |
"field": "label" | |
}, | |
"range": [ | |
"#FFF" | |
] | |
} | |
], | |
"axes": [ | |
{ | |
"orient": "bottom", | |
"scale": "x", | |
"format": "s", | |
"tickCount":5, | |
"labelFontSize": 12, | |
"title": "Hectares (k = 1,000; M = 1,000,000)", | |
"titleFontSize": 14, | |
"font": "Fira Sans" | |
} | |
], | |
"marks": [ | |
{ | |
"name": "bars", | |
"type": "rect", | |
"from": { | |
"data": "table" | |
}, | |
"encode": { | |
"enter": { | |
"y": { | |
"scale": "y", | |
"field": "group" | |
}, | |
"height": { | |
"scale": "y", | |
"band": 1, | |
"offset": -5 | |
}, | |
"x": { | |
"scale": "x", | |
"field": "y0" | |
}, | |
"x2": { | |
"scale": "x", | |
"field": "y1" | |
}, | |
"stroke": { | |
"scale": "colorStroke", | |
"field": "label" | |
}, | |
"strokeWidth": { | |
"value": 0.5 | |
}, | |
"fill": { | |
"scale": "color", | |
"field": "label" | |
}, | |
"tooltip": { | |
"signal": "datum.label + ': ' + format(datum.value, ',') + ' ha'" | |
} | |
}, | |
"update": { | |
"fillOpacity": { | |
"value": 1 | |
} | |
}, | |
"hover": { | |
"fillOpacity": { | |
"value": 0.8 | |
} | |
} | |
} | |
} | |
], | |
"legends": [ | |
{ | |
"fill": "color", | |
"orient": "bottom", | |
"titleFontSize": 14, | |
"labelFontSize": 12, | |
"font": "Fira Sans", | |
"titleLimit": 240 | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment