Platform
Resources
Pricing
Sign in
Get started
Visionscarto
Maps — and other representations of the world.
Workspace
Fork
Public
#30DayMapChallenge
By
Fil
Edited
Aug 19, 2023
9 stars
Insert cell
Insert cell
Insert cell
function
walkOnSpheres
(
point
,
steps
=
3
)
{
let
closest
;
while
(
steps
--
)
{
// Find the closest point in the reference shapes (uses d3-geo-voronoi).
closest
=
vertices
[
voronoi
.
find
(
...
point
)
]
;
// Pick a point at random on the circle centered on point
// and with a radius extending to closest. For this, we
// define a rotation centered on that point, with a random
// angle, and apply it to the closest point (uses attitude).
point
=
attitude
.
axis
(
point
)
.
angle
(
Math
.
random
(
)
*
360
)
(
closest
)
;
}
return
closest
;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
color
=
d3
.
scaleOrdinal
(
d3
.
shuffle
(
d3
.
quantize
(
d3
.
interpolateSpectral
,
60
)
)
)
Insert cell
d3
=
require
(
"d3@7"
,
"d3-geo-projection@4"
,
"d3-geo-voronoi@2"
,
"d3-geo-polygon@1.9"
)
Insert cell
attitude
=
require
(
"attitude"
)
.
then
(
(
d
)
=>
d
(
)
)
Insert cell
voronoi
=
d3
.
geoVoronoi
(
vertices
)
Insert cell
vertices
=
countries
.
features
.
flatMap
(
(
f
,
i
)
=>
{
const
c
=
d3
.
geoCentroid
(
f
)
;
return
geoVertices
(
f
,
i
)
.
map
(
(
d
)
=>
[
...
d3
.
geoInterpolate
(
d
,
c
)
(
0.03
)
,
d
[
2
]
]
)
;
}
)
Insert cell
world
=
d3
.
json
(
"https://unpkg.com/visionscarto-world-atlas@0.1.0/world/110m.json"
)
Insert cell
land
=
topojson
.
feature
(
world
,
world
.
objects
.
land
)
Insert cell
countries
=
topojson
.
feature
(
world
,
world
.
objects
.
countries
)
Insert cell
import
{
geoVertices
,
contains
}
from
"@fil/distance-to-shore"
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
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
walkOnSpheres
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
arctic
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
steps
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
canada
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
canadaMap
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
imago
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
color
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
attitude
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
voronoi
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
vertices
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
world
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
land
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
countries
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML