Installing tools for d3.geo – 20160306

In Let’s make a map, Mike Bostock describes how to make a modest map from scratch using D3 and TopoJSON. Here we detail how to install the main tools on our CentOS 6x server.

Installing Tools

Geographic data files are almost always too large for manual cleanup or conversion. Fortunately, there’s a vibrant geo open-source community, and many excellent free tools to manipulate and convert between standard formats.


The big multitool to know is the Geospatial Data Abstraction Library. Commonly referred to as GDAL, it includes the OGR Simple Features Library and the ogr2ogr binary we’ll use to manipulate shapefiles. There are official GDAL binaries for a variety of platforms – our hosted service runs on CentOS 6x.

The Enterprise Linux GIS (ELGIS) effort provides RPMs of various GIS applications, including GDAL, for CentOS and other Enterprise Linux derivatives. To upload the release RPM for CentOS 6x:

sudo rpm -Uvh

To install GDAL:

sudo yum install -y gdal

… but this generates a lot of dependency errors. In the end, the most significant issue we had to address was GDAL requirement for armadillo-3x instead of the newer (and not backward-compatible vis-a-vis GDAL) armadillo-4x.

We tracked down a copy of armadillo-3.800.2-1.el6.src.rpm, uploaded it to our /root directory, and installed:

sudo rpm -Uvh armadillo-3.800.2-1.el6.x86_64.rpm

… and then we were able to install the GDAL RPM package, as above.

Miscellaneous things we did along the way to installing GDAL

While we’re uncertain of their ultimate significance, we installed/compiled some resources that are worth noting:

Some of the missing dependencies that were flagged up to us were addressed by installing two packages:

su -c 'rpm -Uvh

su -c 'rpm -Uvh'

We also compiled proj4 and geos:

tar -zxvf proj-4.6.0.tar.gz
cd proj-4.6.0
sudo make install

cd ..
tar -jxvf geos-3.0.0.tar.bz2
cd geos-3.0.0
sudo make install
# add lib path to file
sudo vi /etc/
# add this line
sudo /sbin/ldconfig
# Add lib path to file
sudo vi /etc/
# add this line
sudo /sbin/ldconfig


Next you’ll need the reference implementation for TopoJSON, which requires Node.js. Fortunately, we’d already arranged for our host to install Node.js. To install TopoJSON:

npm install -g topojson

… which throws a warning: {several modules} requires inherits@’2′ but will load – even after we install pm2:

npm install pm2 -g

[note: when we were trying to merge shp files, threw error that someone suggested would be fixed by uninstalling topojson and re-installing with sudo -H npm install -g topojson]

To check the installation:

which ogr2ogr
# prints /usr/local/bin/ogr2ogr
which topojson
# prints /usr/local/bin/topojson