Skip to content

Instantly share code, notes, and snippets.

@tmcw
Last active December 28, 2015 03:38
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tmcw/7436261 to your computer and use it in GitHub Desktop.
Hexer is Cool

hexer is cool. It's a new project by Howard Butler that makes hexagon binned files out of point files.

Building hexer

This worked on my system (OSX 10.9, git via homebrew)

git clone https://github.com/hobu/hexer.git
cd hexer
sh hobu-config.sh
make
sudo make install

Sample Data

Download EPA Shapefile of Superfund sites and stuff

Unzip those files and make a spherical mercator version.

unzip EPA_ShapefileDownload_07212013.zip
ogr2ogr -t_srs EPSG:900913 frs_merc FRS_Facilities.shp

Running hexer

Then make the bins. The --edge option lets you control how big the bins are - experiment with a few values to determine what the best ratio of accuracy versus aggregation is for your dataset.

./curse density --input=frs_merc/FRS_Facilities.shp --output=binned.shp --edge 1000

Rendering

I used TileMill to render the result, but it's a Shapefile so you can use anything.

#binned {
  polygon-opacity:0.8;
}
#binned[COUNT > 0] {
  polygon-fill:#e0ecf4;
}
#binned[COUNT > 50] {
  polygon-fill:#9ebcda;
}
#binned[COUNT > 100] {
  polygon-fill:#8856a7;
}

Finished TileMill Map

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