Platform
Resources
Pricing
Sign in
Get started
Adam Roberts
Workspace
Fork
Public
Geospatial
By
Adam Roberts
Edited
Dec 14, 2022
Importers
Insert cell
Insert cell
getZXYTile
=
(
{
lat
,
lng
,
zoom
}
)
=>
{
// return ZXY array
return
[
zoom
,
lon2tile
(
lng
,
zoom
)
,
lat2tile
(
lat
,
zoom
)
]
;
}
Insert cell
lon2tile
=
(
lon
,
zoom
)
=>
{
return
Math
.
floor
(
(
(
lon
+
180
)
/
360
)
*
Math
.
pow
(
2
,
zoom
)
)
;
}
Insert cell
lat2tile
=
(
lat
,
zoom
)
=>
{
return
Math
.
floor
(
(
(
1
-
Math
.
log
(
Math
.
tan
(
(
lat
*
Math
.
PI
)
/
180
)
+
1
/
Math
.
cos
(
(
lat
*
Math
.
PI
)
/
180
)
)
/
Math
.
PI
)
/
2
)
*
Math
.
pow
(
2
,
zoom
)
)
;
}
Insert cell
tile2long
=
(
x
,
z
)
=>
{
return
(
x
/
Math
.
pow
(
2
,
z
)
)
*
360
-
180
;
}
Insert cell
tile2lat
=
(
y
,
z
)
=>
{
var
n
=
Math
.
PI
-
(
2
*
Math
.
PI
*
y
)
/
Math
.
pow
(
2
,
z
)
;
return
(
180
/
Math
.
PI
)
*
Math
.
atan
(
0.5
*
(
Math
.
exp
(
n
)
-
Math
.
exp
(
-
n
)
)
)
;
}
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
Pin
Add comment
Select
Duplicate
Copy link
Embed
Delete
getZXYTile
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
lon2tile
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
lat2tile
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
tile2long
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
tile2lat
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML