Published
Edited
Oct 28, 2018
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// reupload from https://www.census.gov/geo/maps-data/data/cbf/cbf_tracts.html
buffer = fetch('https://gist.githubusercontent.com/asg017/2cdeb7063740a52ebd69237bb0994039/raw/470a676a35c3d08b221b9998cf722aa55a113a56/cb_2017_72_tract_500k.zip')
.then(r=>r.arrayBuffer())

Insert cell
Insert cell
data = zip(buffer, {base64: false, checkCRC32: true}).files
Insert cell
Insert cell
geojson = {
const fileNames = Object.keys(data);
const name = fileNames[0].substring(0, fileNames[0].indexOf('.'))
if( !data[`${name}.shp`] || !data[`${name}.dbf`]) {
throw Error(`No .shp or .dbf for ${name}!`)
}

return shapefile.read(data[`${name}.shp`].asArrayBuffer(),data[`${name}.dbf`].asArrayBuffer() )
}
Insert cell
Insert cell
plot(geojson)
Insert cell
Insert cell
Insert cell
shapefile = require('shapefile')
Insert cell
zip = require("https://bundle.run/node-zip")
Insert cell
import {plot} from '@asg017/quick-map'
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.
Learn more