{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Rotating globe animation depicting earthquake locations", "usermeta": { "Author": "Andrzej Leszkiewicz", "Github": "https://github.com/avatorl/Deneb-Vega/", "License": "CC BY 4.0 (Share and Adapt with Attribution)", "Data Source URL (topojson)": "https://github.com/topojson/world-atlas", "Data Source URL": "https://earthquake.usgs.gov/earthquakes/feed/v1.0/csv.php" }, "width": 500, "height": 500, "padding": 5, "autosize": "pad", "background": "#000022", "signals": [ { "name": "globeRotationAngle", "description": "changes from 0 to -180 and then from 180 to 0", "init": "0", "on": [ { "events": "timer{100}", "update": "globeRotationAngle==-180?180:globeRotationAngle-1" } ] }, {"name": "backSideColor", "value": "#AAAAAA"} ], "data": [ {"name": "sphere", "values": [{"type": "Sphere"}]}, { "name": "worldMap", "url": "https://raw.githubusercontent.com/avatorl/Deneb-Vega/main/earthquakes-globe/countries-110m.json", "format": {"type": "topojson", "feature": "countries"} }, { "name": "earthquakes", "url": "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.csv", "format": {"type": "csv", "parse": "auto", "delimiter": ","}, "transform": [ { "type": "geopoint", "projection": "projection", "fields": ["longitude", "latitude"], "as": ["x", "y"] }, {"type": "collect", "sort": {"field": ["mag"], "order": ["ascending"]}} ] } ], "projections": [ { "name": "projection", "scale": 225, "type": "orthographic", "translate": {"signal": "[width/2, height/2]"}, "rotate": [{"signal": "-globeRotationAngle"}, 0, 0] } ], "scales": [ { "name": "scaleColor", "type": "linear", "domain": [2, 6, 9], "range": ["white", "yellow", "red"] }, { "name": "scaleSize", "type": "pow", "domain": [0, 2, 6, 9], "range": [0.1, 10], "exponent": 2 } ], "title": { "text": { "signal": "'Earthquakes with magnitude 2.5+, last 30 days (live feed)'" }, "subtitle": "", "subtitlePadding": 5, "dy": -10, "anchor": "start", "color": "#DDDDDD", "font": {"value": "Tahoma"}, "fontSize": {"value": 18}, "fontWeight": "lighter" }, "legends": [ { "type": "symbol", "fill": "scaleColor", "orient": "left", "tickCount": 8, "title": "Magnitude", "titleColor": {"signal": "'#DDDDDD'"}, "titleFont": "Tahoma", "titleFontSize": 14, "titleFontWeight": "lighter", "titleAlign": "center", "titleOrient": "top", "titlePadding": 20, "labelColor": {"signal": "'#DDDDDD'"}, "labelAlign": "right", "labelFontSize": 13, "format": ".4", "encode": { "symbols": { "enter": {"size": {"scale": "scaleSize", "signal": "datum.value"}} }, "labels": {"enter": {"dx": {"value": 25}}} } } ], "marks": [ { "type": "shape", "name": "globe", "from": {"data": "sphere"}, "encode": { "update": { "fillOpacity": {"value": 0}, "stroke": {"value": "blue"}, "strokeWidth": {"value": 5}, "strokeOpacity": {"value": 0.3} } }, "transform": [{"type": "geoshape", "projection": "projection"}] }, { "type": "shape", "name": "countries", "from": {"data": "worldMap"}, "encode": { "update": { "fill": {"value": "mintcream"}, "fillOpacity": {"value": 0.1}, "stroke": {"value": "white"}, "strokeWidth": {"value": 0.2} } }, "transform": [{"type": "geoshape", "projection": "projection"}] }, { "type": "symbol", "shape": "circle", "from": {"data": "earthquakes"}, "encode": { "update": { "tooltip": {"signal": "datum.mag"}, "xc": {"signal": "datum.x"}, "yc": {"signal": "datum.y"}, "fill": { "signal": "(abs(globeRotationAngle)<=90?datum.longitude>=(globeRotationAngle-90)&&datum.longitude<=(globeRotationAngle+90)?1:0:globeRotationAngle<-90?datum.longitude>(globeRotationAngle-90+360)||datum.longitude<(globeRotationAngle+90)?1:0:globeRotationAngle>90?datum.longitude>(globeRotationAngle-90)||datum.longitude<(globeRotationAngle-180-90)?1:0:0)==1?scale('scaleColor',datum.mag):backSideColor" }, "opacity": {"value": 1}, "strokeWidth": {"value": 0}, "size": { "scale": "scaleSize", "signal": "(abs(globeRotationAngle)<=90?datum.longitude>=(globeRotationAngle-90)&&datum.longitude<=(globeRotationAngle+90)?1:0:globeRotationAngle<-90?datum.longitude>(globeRotationAngle-90+360)||datum.longitude<(globeRotationAngle+90)?1:0:globeRotationAngle>90?datum.longitude>(globeRotationAngle-90)||datum.longitude<(globeRotationAngle-180-90)?1:0:0)*datum.mag" } } } } ] }