Platform
Solutions
Resources
Pricing
Sign in
Sign up
Development Seed
Winning with Open Data
Workspace
Fork
Public
By
Kyle Barron
Edited
Jan 4, 2024
Insert cell
Insert cell
mapContainer
=
html
`<div style="height:500px"></div>`
Insert cell
flatgeobufBuffer
=
fetch
(
"https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/UScounties.fgb"
)
.
then
(
(
response
)
=>
response
.
arrayBuffer
(
)
)
Insert cell
arrowTable
=
{
const
wasmGeoTable
=
flatgeobufWasm
.
readFlatGeobuf
(
new
Uint8Array
(
flatgeobufBuffer
)
)
;
const
wasmArrowTable
=
wasmGeoTable
.
intoTable
(
)
;
const
jsTable
=
apacheArrow
.
tableFromIPC
(
wasmArrowTable
.
intoIPCStream
(
)
)
;
return
jsTable
;
}
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.
Insert cell
deckglLayer
=
{
const
layer
=
new
geoarrowDeckLayers
.
GeoArrowSolidPolygonLayer
(
{
id
:
"counties"
,
data
:
arrowTable
,
getFillColor
:
[
0
,
100
,
60
,
160
]
,
// I have a bug here.. turns out I can't use table._offsets!
// pickable: true,
// autoHighlight: true,
}
)
deckglMap
.
setProps
(
{
layers
:
[
layer
]
}
)
;
return
layer
;
}
Insert cell
Insert cell
deck
=
require
.
alias
(
{
h3
:
{
}
}
)
(
"deck.gl@8.9.27/dist.min.js"
)
Insert cell
deckglMap
=
{
// This is an Observable hack: clear previously generated content
mapContainer
.
innerHTML
=
""
;
return
new
deck
.
DeckGL
(
{
// The HTML container to render into
container
:
mapContainer
,
map
:
mapboxgl
,
mapStyle
:
"https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json"
,
// Viewport settings
initialViewState
:
{
longitude
:
-
111.91530172951025
,
latitude
:
40.63403641639511
,
zoom
:
4
,
pitch
:
0
,
bearing
:
0
}
,
controller
:
true
}
)
;
}
Insert cell
// Load the flatgeobuf-wasm library
flatgeobufWasm
=
{
const
module
=
await
import
(
"https://unpkg.com/@geoarrow/flatgeobuf-wasm@0.2.0-beta.1/esm/index.js"
)
;
// Need to await the default export first to initialize the WebAssembly code
await
module
.
default
(
)
;
return
module
;
}
Insert cell
apacheArrow
=
require
(
"apache-arrow@14"
)
Insert cell
mapboxgl
=
require
(
"mapbox-gl@1.6.0/dist/mapbox-gl.js"
)
Insert cell
mathGlPolygon
=
import
(
"https://cdn.jsdelivr.net/npm/@math.gl/polygon@3.6.2/+esm"
)
Insert cell
geoarrowDeckLayers
=
require
.
alias
(
{
"@deck.gl/core/typed"
:
deck
,
"@deck.gl/layers/typed"
:
deck
,
"apache-arrow"
:
apacheArrow
,
"@math.gl/polygon"
:
mathGlPolygon
,
}
)
(
"@geoarrow/deck.gl-layers@0.2.0"
)
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
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mapContainer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
flatgeobufBuffer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
arrowTable
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
deckglLayer
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
deck
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
deckglMap
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
flatgeobufWasm
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
apacheArrow
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mapboxgl
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mathGlPolygon
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
geoarrowDeckLayers
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML