All examples By author By category About

azza-bazoo

CatMap: because lolcats need projection too

This is a map of the Australian state of Victoria, showing some of the locations for which cat registration data is available publicly. A bigger cat on the map means there are more real cats in that postcode; pan and zoom to explore.

You might say it's a map of cats, or a CatMap!

im in ur javascript, referencing decade-old memes

Preparing the map

Take a shapefile of "postal areas" from the Australian Bureau of Statistics. Using GDAL, find the postcodes in Victoria (starting with 3), and convert to GeoJSON. Then, run through TopoJSON for fancy lossless compression, and run our own postcode-centroids.js to generate display positions.

ogr2ogr -f GeoJSON -simplify 0.01 -where "SUBSTR(POA_CODE16, 1, 1) = '3'" victoria.geojson POA_2016_AUST.shp
node_modules/.bin/topojson -o victoria.json victoria.geojson
node postcode-centroids.js victoria.geojson

Fluffy feline figures

We want to collect data that has cats, and postcodes. In our case we have the City of Ballarat and the City of Greater Dandenong. Some spreadsheet trickery is required to convert things to consistent format (e.g. converting month of birth -> age) and put them in a single file for ease of consumption.

Drawing with D3

First we draw the base map from the TopoJSON file using The Functions Formerly Known As "d3.geo", with an added splash of d3.zoom to make it look more like a real web map.

Then we load the CSV file containing cat data; for each postcode, we count the number of cats, and add a element with a cat emoji! Its position is given by the centroids calculated earlier, and its font-size comes from the number of cats we counted.

There are, of course, not enough cats. NEED MOAR DATA!