Skip to content

Instantly share code, notes, and snippets.

@nitaku
Last active December 31, 2015 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitaku/8031205 to your computer and use it in GitHub Desktop.
Save nitaku/8031205 to your computer and use it in GitHub Desktop.
Fractal tree depth map (random, Gosper)

Full source, including python scripts, here.

An original extension of the fractal treemap technique shown in the previous example, this map shows the depth of each leaf (hexagon) using a color encoding. The result resembles an orographic, physical map (with tree depth in place of terrain elevation), while the fractal treemap resembles a political map.

The regions, forming a sort of contour map, are computed offline by running gosper_depth_contour_lines.py, a slightly modified version of the gosper_regions.py script that creates the treemap.

run gosper_regions.py
gosperify('tree_48207.csv', 'hexes.wkt.csv', 'depth_regions.json') # input tree, input tiling, output file
topojson --cartesian --no-quantization -p depth -o depth_regions.topo.json depth_regions.json

The random tree is the same of the previous example, containing 48,207 leaves (the script took about 10 hours to finish!).

The colors of the quantize scale are taken from Gretchen N. Peterson's Cartographer's Toolkit (page 38). The halo that makes the numbers in the legend readable is created by defining four text-shadows in CSS, a technique found here.

The obtained map is somehow uninteresting, showing an apparently uniform distribution of mountains and valleys. This has obviously something to do with the fact that the tree is randomly generated. A more interesting experiment will be to create such a map from real data.

As a way to obtain more readable regions, a depth-based tree ordering algorithm could be performed prior to feeding the tree into the system. This way, higher-depth regions (mountains) should be placed near to each other.

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment