Skip to content

Instantly share code, notes, and snippets.

@ragnarheidar
Last active October 6, 2016 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ragnarheidar/8b24d60f0b0aa6243fc97cd9fe65fe5d to your computer and use it in GitHub Desktop.
Save ragnarheidar/8b24d60f0b0aa6243fc97cd9fe65fe5d to your computer and use it in GitHub Desktop.
Earthquake map for Iceland

A Carto map that shows earthquakes in Iceland for the past 48 hrs.

Data retrieved with Python with Beautiful Soup. Earthquake data is from automatic processing and might include errors. Only earthquakes with a measurement quality higher or equal than 50 are used.

Python code gist

Earthquake data: Icelandic Met Office Glacier outlines: National Land Survey of Iceland Lava fields: The Icelandic Institute of Natural History

This map was setup to be updated every hour with Python code using the Beautiful Soup library and CartoDB SQL API. The code runs on a Raspberry Pi model B+

<!DOCTYPE html>
<html>
<head>
<title>Earthquakes in Iceland | Past 48 hrs</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>
<!-- include cartodb.js library -->
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
<script>
function main() {
cartodb.createVis('map', 'https://ragnarheidar.carto.com/api/v2/viz/6365d812-2e1a-11e4-8988-0e230854a1cb/viz.json', {
shareable: true,
title: false,
description: false,
search: false,
tiles_loader: true,
center_lat: 65,
center_lon: -18.5,
zoom: 6
})
.done(function(vis, layers) {
// layer 0 is the base layer, layer 1 is cartodb layer
// setInteraction is disabled by default
layers[1].setInteraction(true);
layers[1].on('featureOver', function(e, latlng, pos, data) {
cartodb.log.log(e, latlng, pos, data);
});
// you can get the native map to work with it
var map = vis.getNativeMap();
// now, perform any operations you need
// map.setZoom(3);
// map.panTo([50.5, 30.5]);
})
.error(function(err) {
console.log(err);
});
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment