Public
Edited
Mar 20, 2023
1 star
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
strat2 = {
//let col= 55; //Enter macrostrat column id here
//let url="https://macrostrat.org/api/sections?col_id=" + col + "&response=long";
let url="https://macrostrat.org/api/sections?lat=58.9700&lng=5.7331&response=long";
return d3.json(url);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//lithWithPatterns.success.data.find(({ lith_id }) => lith_id === 68).pattern //Change lith_id to a different number to see representations of other rock types. Reference - https://davenquinn.com/projects/geologic-patterns/
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
strat.success.data[3]
Insert cell
strat.success.data[0].lith
Insert cell
strat.success.data[0].environ
Insert cell
strat.success.data
Insert cell
function findFirstUnitMoreThanXThick(strat,X){
//// Finds the first unit from the top that has at least 15 max thickness. If none, returns the first unit.
//// This can be used to report the first large unit if an area is covered by a thin layer of alluvium that the user wants to ignore for example.
for (let i = 0; i < strat.success.data.length; i++) {
if (strat.success.data[i].max_thick > X){
return i
}
}
return 0
}
Insert cell
function play(strat,unit_order_starting_from_top) {
if ('speechSynthesis' in window) {
let top_strat = strat.success.data[unit_order_starting_from_top]
let intro_message = ""
if (unit_order_starting_from_top == 0){
intro_message = "The following is about the top unit present at this location."
}
if (unit_order_starting_from_top == 1){
intro_message = "The following is about the second from the top unit present at this location."
}
//// INTRO
let intro = new SpeechSynthesisUtterance(intro_message);
window.speechSynthesis.speak(intro);
//// How many lithologies
let names_of_lith = []
let highest_prop_lith = {"lith":"there's a problem in the code","prop":0}
////
let names_of_environ = []
let highest_prop_environ = {"environ":"there's a problem in the code","prop":0}
for (let i = 0; i < top_strat.lith.length; i++) {
if (top_strat.lith[i].prop >= highest_prop_lith.prop){
highest_prop_lith.lith = top_strat.lith[i].name
highest_prop_lith.prop = top_strat.lith[i].prop
}
names_of_lith.push(top_strat.lith[i].name)
}
for (let i = 0; i < top_strat.environ.length; i++) {
if (top_strat.environ[i].prop >= highest_prop_environ.prop){
highest_prop_environ.environ = top_strat.environ[i].name
highest_prop_environ.prop = top_strat.environ[i].prop
}
names_of_environ.push(top_strat.environ[i].name)
}
let length_of_lithos = top_strat.lith.length
let working = new SpeechSynthesisUtterance("This unit has "+top_strat.lith.length+" lithologies.");
window.speechSynthesis.speak(working);
// AGE
let workingAge = new SpeechSynthesisUtterance("The unit's age is between "+Math.round(top_strat.t_age)+" and "+Math.round(top_strat.b_age)+" million of years old.");
window.speechSynthesis.speak(workingAge);
// THICKNESS
let working4 = new SpeechSynthesisUtterance("The max thickness of this unit near this location is "+ Math.round(top_strat.max_thick)+".");
window.speechSynthesis.speak(working4);
// Lithologies
let working_common_lith = new SpeechSynthesisUtterance("The most common lithology at "+Math.round(highest_prop_lith.prop*100)+ " percent of this unit is "+highest_prop_lith.lith+ ". Other lithologies include, "+names_of_lith.toString());
window.speechSynthesis.speak(working_common_lith);
// ENVIRONMENT
let working_common_environ = new SpeechSynthesisUtterance("The most common depositional environment at "+Math.round(highest_prop_environ.prop*100)+ " percent of this unit is "+highest_prop_environ.environ+ ". Other lithologies include, "+names_of_environ.toString());
window.speechSynthesis.speak(working_common_environ);
}
else{
document.write("Browser not supported")
}
}
Insert cell
window.speechSynthesis.speak(new SpeechSynthesisUtterance("The max thickness of this unit near this location"))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more