Published
Edited
Jul 10, 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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
projectedPotentialRange = d3.extent(
Object.values(competitionAdjustedPotential)
.map(sources => sources.map(s => s.potential).reduce(arraySum, 0) || 0)
)
Insert cell
projectedPatients = h => competitionAdjustedPotential[h].map(s => s.potential).reduce(arraySum, 0)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ucLayer = {
const markerstyle = d => {
const isCarbon=d.properties["Network"]=="Carbon Health Care (FKA Direct Urgent Care)";
return ({
radius: isCarbon ? 6 : 4,
//fillColor: isCarbon ? "green" : stickyCategoricalColor(d.properties["Network"]),
fillColor: ucColor(googleRatingScore(d.properties)),
fillOpacity: 1,
stroke: true,//d.properties["Network"]=="Carbon Health Care (FKA Direct Urgent Care)",
color: isCarbon ? "white" : "white",
weight: isCarbon ? 2 : 0.5,
opacity: isCarbon ? 1 : 0.5,

})
};
return L.geoJson(urgent_cares, {
filter: d => "0"+d.properties["Full Census Tract"].substr(0,4) == selected_county,
pointToLayer: (feature, latlng) => L.circleMarker(latlng, markerstyle(feature))
})
.bindTooltip(layer => urgentCareTooltip(layer.feature.properties))
.bindPopup(layer => urgentCareTooltip(layer.feature.properties))
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hexBlocksCompetitionAdjustedLayer = L.geoJSON(hexBlocks, {
filter: d => d.properties.total,
style: d => ({
weight:1,
opacity:0.15,
color: "gray",//strokeColor(d.properties.highIncome/d.properties.total),
//fill: false,
fillOpacity: 0.5,
fillColor: d3.scaleLinear()
.domain(projectedPotentialRange)
.range(["red" ,"green"])
.interpolate(d3.interpolateLab)
(projectedPatients(d.id))
})
})
.bindPopup(function (layer) {
return popup(layer.feature.properties);
})
//competitionAdjustedPotential
Insert cell
Insert cell
Insert cell
Insert cell
carbonConversionRange=d3.extent(hexBlocks.features.map(d => d.properties.carbonPatients.length/d.properties.total))
Insert cell
carbonConversionLayer={
return L.geoJSON(hexBlocks, {
filter: d => d.properties.carbonPatients.length>10,
style: d => ({
weight:1,
opacity:0.15,
color: "gray",//strokeColor(d.properties.highIncome/d.properties.total),
//fill: false,
fillOpacity: 0.6,
fillColor: d3.scaleLinear()
.domain(carbonConversionRange)
.range(["white" ,"blue"])
.interpolate(d3.interpolateLab)
(d.properties.carbonPatients.length/d.properties.total)
})
})
.bindPopup(function (layer) {
return popup(layer.feature.properties);
})
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
competitionAdjustedPotential = _.groupBy(
hexBlocks
.features
//.slice(0, 10)
.map(d => {
const nearby=nearbyUrgentCares(d.id);
const totalScore=nearby.map(u => u.score).reduce(arraySum, 0);
return h3.kRingDistances(d.id, maxDistance)
.map((hs, dist) => hs.map(h => {
const expectedScore=urgentCareWeightFunc({dist, reviewScore: carbonClinicScore});
const patientsInBlock=estimatedAnnualVisits(d.properties) || 0;
return {
from: d.id,
to: h,
potential: expectedScore/(expectedScore+totalScore)*patientsInBlock
};
}))
.reduce(arrayMerge, []);
})
.reduce(arrayMerge, []),
o => o.to
)
Insert cell
nearbyUrgentCares = h =>
h3.kRingDistances(h, maxDistance)
.map((blocks, dist) =>
blocks.map(h2 => {
const ind = hexBlockIndex.get(h2);
return ind ?
hexBlocks.features[ind].properties.urgentCares :
[];
})
.reduce(arrayMerge, [])
.map(ind => ({
dist,
ind,
reviewScore: googleRatingScore(urgent_cares.features[ind].properties),
score: urgentCareWeightFunc({
dist,
reviewScore: googleRatingScore(urgent_cares.features[ind].properties)
}),
name: urgent_cares.features[ind].properties["Urgent Care Clinic Name"]
}))
)
.reduce(arrayMerge, [])
.sort((a,b) => b.score - a.score)
Insert cell
nearbyUrgentCares("8828308129fffff")
Insert cell
urgentCareWeightFunc = ({dist, reviewScore}) =>
reviewScore/(2+dist);
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {mutableForm} from "@mootari/mutable-forms"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
geojson2h3=require('https://bundle.run/geojson2h3@1.0.1')
Insert cell
esri=require("https://unpkg.com/@esri/arcgis-to-geojson-utils")
Insert cell
Insert cell
Insert cell
arraySum = (a,b) => a+b;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
proxy="https://observable-cors.glitch.me/";
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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