Public
Edited
Feb 21, 2023
Insert cell
md`# GEOG VIS Assignment 1`
Insert cell
d3 = require("d3@5")
Insert cell
topojson = require("topojson-client@3")
Insert cell
njCounty = FileAttachment("County_Boundaries_of_NJ[1].json").json()
Insert cell
njCounty_feature = topojson.feature(njCounty, njCounty.objects.County_Boundaries_of_NJ)
Insert cell
csv_data = d3.csvParse(await FileAttachment("County_Boundaries_of_NJ.csv").text(),({POP2010, SQ_MILES, COUNTY}) => [COUNTY, [POP2010/SQ_MILES]])
Insert cell
//this is how to take the values of a variable (column) from all variables you created from the csv file
njPopDensity = Array.from(csv_data.values(), d => d[1][0])
Insert cell
//this is how you map the id column to the values. We will use this for joining with topojson later.
data = Object.assign(new Map(csv_data), {title: ["Population Density", "County Name"]})
Insert cell
unclass = d3.scaleLinear().domain([d3.min(njPopDensity),d3.max(njPopDensity)]).range("White","Red")
Insert cell
chart = (data, unclass)
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