Chapter 19. Mapping with D3
Building and customizing map visualizations is one of D3âs core strengths. It has some very sophisticated libraries, allowing for all kinds of projections, from the workhorse Mercator and orthographic to more esoteric ones such as Conic Equidistant. Mapping seems to be something of an obsession for Mike Bostock and Jason Davies, D3âs core devs, and their attention to detail is striking. If you have a mapping problem, chances are D3 can do the heavy lifting required.1 In this chapter, weâll use our Nobel Prize visualization (Nobel-viz) map (Figure 19-1) to introduce the core D3 mapping concepts.
Available Maps
The most popular mapping format is the aging shapefile, developed for geographic information system (GIS) software. There are many free and proprietary desktop programs2 to manipulate and produce shapefiles.
Unfortunately, shapefiles were not designed for the web, which would far rather deal in a JSON-based map format, and demands small, efficient representations to limit bandwidth and related lag.
The good news is that there are many convenient ways to convert shapefiles to our preferred TopoJSON format,3 meaning you can manipulate your shapefiles in software and then convert them to a web-friendly format. The standard way of finding maps for web dataviz is to first look for TopoJSON or GeoJSON ...
Get Data Visualization with Python and JavaScript, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.