Platform
Solutions
Resources
Pricing
Sign in
Sign up
Kelsey Matsik
Workspace
Fork
Public
By
Kelsey Matsik
Edited
Apr 6, 2023
Fork of
Plot World Map
1
Insert cell
Insert cell
viewof
form
=
Inputs
.
form
(
{
// creates interactivity
projection
:
Inputs
.
select
(
[
"equal-earth"
,
"mercator"
,
"orthographic"
]
,
{
label
:
"Projection"
}
)
,
// projections you csn switch between
lat
:
Inputs
.
range
(
[
-
90
,
90
]
,
{
label
:
"Latitude"
,
step
:
1
}
)
,
//adjust latitude
lon
:
Inputs
.
range
(
[
-
180
,
180
]
,
{
label
:
"Longitude"
,
step
:
1
}
)
,
//adjust longitude
}
)
Insert cell
Plot
.
plot
(
{
projection
:
{
type
:
form
.
projection
,
//apply form
rotate
:
[
-
form
.
lon
,
-
form
.
lat
]
// center rotation around a given set or coordinates
}
,
//"mercator" --> flat map, "orthographic" --> sphere "equal-earth" --> double-globe
width
:
500
,
marks
:
[
Plot
.
geo
(
world110m
,
{
//fill: "#eee",
fill
:
d
=>
{
if
(
d
.
id
==
"USA"
)
{
return
"blue"
}
else
if
(
d
.
id
==
"CHN"
)
{
return
"red"
}
else
return
"#eee"
}
,
stroke
:
"#ccc"
}
)
,
//plot.geo plots the outline of the countries
//Plot.graticule(), //plot.graticule plots the latitude/longitude lines
Plot
.
geo
(
usstates
,
{
fill
:
"#eee"
,
stroke
:
"#ccc"
}
)
,
//plots individual states in US
Plot
.
geo
(
cville
,
{
stroke
:
"blue"
}
)
,
// when replacing plot.geo(land) with plot.geo(world110m), we can see each individual outline from the file imported below
Plot
.
sphere
(
{
stroke
:
"#ccc"
}
)
//plot.sphere plots the globe outline
]
}
)
Insert cell
//land = topojson.feature(land50m, land50m.objects.land)
Insert cell
//land50m = FileAttachment("land-50m.json").json()
Insert cell
import
{
basemaps
}
from
"@emfielduva/dvlib_maps"
//import map
Insert cell
world110m
=
(
await
basemaps
.
world110m
.
geojson
)
.
json
(
)
//provides a collection of features; each feature is a country
Insert cell
usstates
=
(
await
basemaps
.
us_states20m
.
geojson
)
.
json
(
)
//.json() tells Java to parse file as a json file
//plots individual states in US
Insert cell
cville
=
d3
.
json
(
"https://opendata.arcgis.com/datasets/c371ad0b81024822bad1147ff6bb24c4_51.geojson"
)
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.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
form
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
world110m
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
usstates
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cville
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML