Published
Edited
Feb 21, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
long = filteredquakes.map(function(d) {return d.geometry.coordinates[0]; });
//longitude from -180 to +180. This has 1209 records while filtered has 1151. There is a misalignmient
Insert cell
lats= filteredquakes.map(function(d) {return d.geometry.coordinates[1]; });
//latitude from -90 to +90
Insert cell
md`Filtering for just North America, but this is wrong, you should filter entire geometry coordinates`
Insert cell
//filteredLats = lats.filter(function (value) {
// return value >= 0;});
Insert cell
Insert cell
filteredquakes = quakes.filter(function(d) {return(d.geometry.coordinates[1] > 0);});
Insert cell
{
// identify x (longitude) and y (latitude) coordinates as being properties of earthquake geojson. putting all attributes in the variable plot1
var plot1 = {
x: long,
y: lats,
mode: 'markers',
type: 'scatter',
marker: { size: 12 }
};
// Layout uses Plot.ly's default aspect ratio, with Observable's "width"
var layout = {
title: 'Earthquakes Coordinates',
height: 500 * width / 800
};

// Plotly's data model for scatterplots
var data = [plot1];
// The call to Plotly.js, using the string "myDiv", which puts the graph in: "<div id='myDiv'></div>
Plotly.newPlot('myDiv', data, layout);
// Return the values so we can see the data Array
return plot1;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more