Last active
October 28, 2016 09:00
-
-
Save letmaik/1adc7a1cc745b0a095da5cccc111cf77 to your computer and use it in GitHub Desktop.
CovJSON minimal visualization example
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
<!DOCTYPE html> | |
<html> | |
<style> | |
html, body, #map { | |
width: 100%; height: 100%; | |
margin: 0; | |
} | |
</style> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css" /> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/leaflet-coverage.css" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.js"></script> | |
<script src="https://unpkg.com/[email protected]/covutils-lite.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/covjson-reader/0.16.3/covjson-reader.min.js"></script> | |
<script src="https://unpkg.com/[email protected]/leaflet-coverage.min.js"></script> | |
<body> | |
<div id="map"></div> | |
<script> | |
var map = L.map(document.getElementById('map'), { center: [10, 0], zoom: 2 }) | |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map) | |
var layers = L.control.layers(null, null, {collapsed: false}).addTo(map) | |
var layer | |
CovJSON.read('temperature.covjson').then(function (coverage) { | |
layer = C.dataLayer(coverage, {parameter: 'temperature'}) | |
.on('afterAdd', function () { | |
C.legend(layer).addTo(map) | |
map.fitBounds(layer.getBounds()) | |
}) | |
.addTo(map) | |
layers.addOverlay(layer, 'Temperature') | |
}) | |
map.on('click', function (e) { | |
new C.DraggableValuePopup({ | |
layers: [layer] | |
}).setLatLng(e.latlng).openOn(map) | |
}) | |
</script> | |
</body> | |
</html> |
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
{ | |
"type" : "Coverage", | |
"domain" : { | |
"type" : "Domain", | |
"domainType" : "Grid", | |
"axes": { | |
"x" : { "start": 7, "stop": 14, "num": 4 }, | |
"y" : { "start": 54, "stop": 48, "num": 4 } | |
}, | |
"referencing": [{ | |
"coordinates": ["x","y"], | |
"system": { | |
"type": "GeographicCRS", | |
"id": "http://www.opengis.net/def/crs/OGC/1.3/CRS84" | |
} | |
}] | |
}, | |
"parameters" : { | |
"temperature": { | |
"type" : "Parameter", | |
"description": { | |
"en": "Air temperature measured in degrees Celsius." | |
}, | |
"unit" : { | |
"label": { | |
"en": "Degree Celsius" | |
}, | |
"symbol": { | |
"value": "Cel", | |
"type": "http://www.opengis.net/def/uom/UCUM/" | |
} | |
}, | |
"observedProperty" : { | |
"id": "http://vocab.nerc.ac.uk/standard_name/air_temperature/", | |
"label" : { | |
"en": "Air temperature", | |
"de": "Lufttemperatur" | |
}, | |
"description": { | |
"en": "Air temperature is the bulk temperature of the air, not the surface (skin) temperature." | |
} | |
} | |
} | |
}, | |
"ranges" : { | |
"temperature" : { | |
"type" : "NdArray", | |
"dataType": "float", | |
"axisNames": ["y", "x"], | |
"shape": [4, 4], | |
"values" : [ | |
17.3, 18.2, 16.5, 18.7, | |
18.1, 19.4, 17.2, 18.6, | |
19.2, 20.4, 21.1, 20.7, | |
21.1, 21.3, 20.5, 19.2 | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo: https://bl.ocks.org/letmaik/1adc7a1cc745b0a095da5cccc111cf77