Platform
Resources
Pricing
Sign in
Get started
University of Iowa
Workspace
Fork
Public
By
Jaob3
Edited
Feb 11
Fork of
My first exercise
2
Insert cell
md
`# My first exercise`
Insert cell
Insert cell
d3
=
require
(
"d3@5"
)
Insert cell
topojson
=
require
(
"topojson-client@3"
)
Insert cell
1
counties
=
FileAttachment
(
"counties_us_cont_2020_wgs84.json"
)
.
json
(
)
Insert cell
1
county_features
=
topojson
.
feature
(
counties
,
counties
.
objects
.
counties_us_cont_2020_wgs84
)
Insert cell
1
csv_data
=
d3
.
csvParse
(
await
FileAttachment
(
"assignment1_county_csv@2.csv"
)
.
text
(
)
,
(
{
STATE
,
AREALAND1
,
AV0AA2020
}
)
=>
(
[
STATE
,
AV0AA2020
/
AREALAND1
]
)
)
Insert cell
//this is how to take the values of a variable (column) from all variables you created from the csv file
PopulationDensity
=
Array
.
from
(
csv_data
.
values
(
)
,
d
=>
d
[
1
]
)
Insert cell
1
//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
:
[
"States"
,
"Population_Density"
]
}
)
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.
Try it for free
Learn more
Compare fork
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
topojson
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
counties
Show 1 comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
county_features
Show 1 comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
csv_data
Show 1 comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
PopulationDensity
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Show 1 comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML