Published
Edited
Jul 27, 2019
4 forks
6 stars
Contour Labels (canvas)Coordinated mapsgeoformatSmall circle testKruskal MazeAll the geoshapesReprojecting Vector TilesCloud ContoursHello h3-jsClipping AlbersTranslucent EarthThe truth about the Mercator projectionUsing d3-inertia with observableMercator projection of a Mercator globeD3 Vector Tiles (WIP)Finding intersections between the graticule and the clip sphere of the stereographic projection, method 2Plate tectonicsAnother hex mapEquateur & tropiquesTissot's indicatrixDistance to shoreMultiPolygon clippingSouth Africa’s medial axisSpherical intersectionVolcano Semis (points circulaires)Pencil Airocean45° mapNetCDFBlue noise sphereRubber DymaxionSpherical quasi-random (R2) distributionAutomated label placement (countries)Automated label placement (France)Automated label placement (cities)d3.geoIntersectArcDelaunay.findTriangled3-geo-voronoi and gridded dataElevation vtk.jsMapfillKrigingSpherical HeatmapReproject elevation tiles — detail
Reproject elevation tiles — world
Fisheye Conformal MapSpherical KDE InterpolationSpherical kernel interpolation with nearest neighborsShepard’s methodModified Shepard’s methodSpherical contoursGeo Voronoi interpolationBlurry contoursHow much warmer? (BBC)H3 hexagons & geoContoursHillshading & supersamplingH3 odditiesManhattan VoronoiManhattan Voronoi IIGeoJSON feature editorColorized Manhattan Spanning Treelegra mapslegra country mapsThe complex logarithm projectionCountries small multipleThe 2D approximate Newton-Raphson methodOceanAttitudeCount visible objectsThe Gray-Fuller spatial gridGray-Fuller grid metricsGray-Fuller grid odditiesSpherical smallest-circle problemBounding CirclesCountries Enclosing CirclesFullscreen Seamless Zoomable Map TilesMap Pan & ZoomSpherical EllipsesSynchronized projectionsThe closest countryTriangular tiling of icosahedronHello, polygon-clippingCorées / KoreasHello, procedural-glHello, placekeyZoom World ChoroplethClipping spherical polygonsSpherical phyllotaxisFour-color world map with ClingoHello, jsgeoda!The Sun’s analemmaWorld of squaresWorld of squares (spherical)A map of AfricaTagged bordersClipped geoVoronoiBlue noise sphere IISpherical Perlin NoiseSpherical Delaunay triangulationDynamic simplificationRewindPlot: Voronoi labelsAoC 12: shortest path under constraintsHello, pixi.jsFlight PathsRay out of a convex hullDistance to a segment
Also listed in…
Projections
Insert cell
Insert cell
Insert cell
projection = d3
.geoCahillKeyes()
.fitExtent([[1, 1], [width - 1, height - 1]], outline)
Insert cell
earth = d3.scaleSequential(d3.interpolateOranges).domain([0, 5000])
Insert cell
sea = d3.scaleSequential(d3.interpolateBlues).domain([0, -8000])
Insert cell
Insert cell
url = (x, y, z) =>
`https://tile.nextzen.org/tilezen/terrain/v1/256/terrarium/${z}/${x}/${y}.png?api_key=${api_key}`
Insert cell
w = tileSize
Insert cell
h = tileSize
Insert cell
mutable dem = DOM.canvas(w, h)
Insert cell
// the DEM tiles we load should encompass the whole area, and fall on exact screen coordinates (tx, ty are integers, and k equal to 256.
mercator = {
const mercator = d3.geoMercator().fitExtent([[0, 0], [w, h]], outline),
tiles = d3
.tile()
.size([w, h])
.scale(mercator.scale() * 2 * Math.PI)
.translate(mercator([0, 0]))(),
k = tileSize / tiles.scale;
return mercator
.scale(mercator.scale() * k)
.translate(mercator.translate().map(d => Math.round(d * k)));
}
Insert cell
tiles = d3
.tile()
.size([w, h])
.scale(mercator.scale() * 2 * Math.PI)
.translate(mercator([0, 0]))()
Insert cell
loader = {
const context = mutable dem.getContext("2d");
context.fillStyle = "#800000";
context.fillRect(0, 0, w, h);
tiles.forEach(([x, y, z], i, { translate: [tx, ty], scale: k }) => {
d3.image(url(...d3.tileWrap([x, y, z])), { crossOrigin: "Anonymous" }).then(
image => {
context.drawImage(image, (x + tx) * k, (y + ty) * k, k, k);
mutable dem = mutable dem;
}
);
});
return `loading ${tiles.length} tiles...`;
}
Insert cell
api_key = "7b1mrgvcThKgwl1ZslAhKQ" // claim your own API key at https://developers.nextzen.org/
Insert cell
Insert cell
rescale = d3.scaleSqrt()
Insert cell
data = {
const d = dem.getContext("2d").getImageData(0, 0, w, h).data,
val = (_, i) => {
const j = (h - 1 - ((i / w) | 0)) * w + (i % w), // flip
v = 256 * d[4 * j] + d[4 * j + 1] + d[4 * j + 1] / 256 - 32768;
return rescale(v);
};
return Float32Array.from({ length: w * h }, val);
}
Insert cell
contours = {
const contours = d3
.contours()
.size([w, h])
.thresholds(50)(data);

for (const c of contours) {
for (const polygon of c.coordinates)
for (const ring of polygon) {
for (var i = 0; i < ring.length; i++)
ring[i] = mercator.invert([ring[i][0] - 0.5, w - (ring[i][1] - 0.5)]); // flop
}
}
return contours;
}
Insert cell
extent = d3.extent(contours, d => rescale.invert(d.value))
Insert cell
Insert cell
// this is the area we want to cover
outline = ({ type: "Sphere" })
Insert cell
height = width / 2
Insert cell
tileSize = 256
Insert cell
d3 = require("d3@5", "d3-geo-projection@2", "d3-geo-polygon@1", "d3-tile@1")
Insert cell
land = d3.json(
"https://unpkg.com/visionscarto-world-atlas@0.0.6/world/110m_land.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.
Learn more