Skip to content

Instantly share code, notes, and snippets.

@curran
Last active May 15, 2019 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save curran/6ba202660d5393fd3f79 to your computer and use it in GitHub Desktop.
Save curran/6ba202660d5393fd3f79 to your computer and use it in GitHub Desktop.
Earth at Night

This is a browsable map of NASA's "Earth at Night" data, showing the human-generated light emanating from Earth at night. This is a nice approximation of population density.

Draws from:

Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS). Map drawn with Leaflet.js.

Built with blockbuilder.org

web counter
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Earth at Night</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
#map { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = L.map('map', {attributionControl: false})
.setView([45.27, 26.98], 4);
// Load the NASA "Earth at Night" tiles.
// This code is copied from http://leaflet-extras.github.io/leaflet-providers/preview/
var NASAGIBS_ViirsEarthAtNight2012 = L.tileLayer('http://map1.vis.earthdata.nasa.gov/wmts-webmerc/VIIRS_CityLights_2012/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}', {
minZoom: 1,
maxZoom: 8,
format: 'jpg',
time: '',
tilematrixset: 'GoogleMapsCompatible_Level'
});
NASAGIBS_ViirsEarthAtNight2012.addTo(map);
map.on("move", function(){
console.log(map.getCenter());
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment