Skip to content
Dan Rope edited this page Mar 13, 2017 · 4 revisions

Brunel comes with a wide variety of common geographic maps. If you need a visualization of a map that Brunel does not internally support then (starting with Brunel 2.3) you can use your own GeoJSON. For example, say you want a map of NYC boroughs using the GeoJSON here: https://github.com/dwillis/nyc-maps/blob/master/boroughs.geojson

1. Convert GeoJSON to topojson

Brunel uses topojson to produce maps so first you must convert the GeoJSON to topojson. To do this you need to install topojson (https://github.com/topojson/topojson). Then, download the raw GeoJSON file and convert it to topojson using a command similar to:

geo2topo --bbox -q 1.000000e+03 -s 8.190905e-06 -p -o boroughs.json all=boroughs.geojson

The values for -q and -s specify the resolution. Values corresponding to Brunel's low, med, high and full are:

low: -q 1.000000e+03 -s 8.190905e-06

med: -q 1.000000e+04 -s 8.190905e-08

high: -q 1.000000e+06 -s 8.190905e-10

full: -q 1e9

2. Locate the property containing values matching your data

Next, you will need to find the name of the geographic feature that is expected to match the values in your data. Look for the properties object that is within geometries and find the property name whose value will match record values in your data. Here it is "BoroName" which has values such as "Queens".

3. Place the topojson file in a visible location

This topojson file must then be placed where it can be loaded via http. If you are using a Jupyter notebook, then the tree folder containing your notebooks will work. Note, the topojson file is used both by Brunel Java code and Javascript. As such, it needs to be visible from wherever the Java is executing as well as the web browser.

4. Make your map

Use the Brunel map action and provide the location of the topojson file and the property name separated by # as in:

data('boroughs') map('http://localhost:8889/tree/notebooks/data/boroughs.json#BoroName') x(Borough) color(value) label(Borough)

In the data, there is a field named "Borough" whose values exactly match the contents of the feature property "BoroName" from the original GeoJSON file. Also, the above URL location was used from a locally running Jupyter notebook (if that's helpful!)