Including the dataset

The necessary data has been provided for you within the data folder, with the filename geo-data.json:

   d3.json('geo-data.json').then(function(data) {     console.log('mexico', data);

We get the data from a Fetch call, as we saw in the previous chapter.

After the data has been collected, we want to draw only those parts of the data that we are interested in. In addition, we want to automatically scale the map to fit the defined height and width of our visualization.

If you look at the console, you'll see that mexico has an objects property. Nested inside the objects property is MEX_adm1. This stands for the administrative areas of Mexico. It is important to understand the geographic data you are using, because other data ...

Get Learning D3.js 5 Mapping - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.