Data from Historical Maps: Extracting Backgrounds

medium (1)As I’ve written on here before, digitizing political maps is no easy task. One tough problem is digitizing background colors which identify things like land cover. Consider this section from a Vietnam War era military map of South Vietnam. There are three background regions, a dark green for forested area, a slightly lighter green for cleared forest, and a white area for completely clear. On top of that are lots of details including brown elevation lines, black grid lines and text, etc.

How do we differentiate the background regions from the foreground regions? Define a background region as a semi-contiguous area with similar but not identical color.

Continue reading…

Python 64bit on Windows

Getting 64bit Python up and running with 64 bit packages on Windows is a bit of a pain.

Install WinPython 64bit,

Register the installation with windows with “WinPython Control Panel.exe” by going “Advanced” -> “Register distribution”

Now find a 64bit compilation of the package you want. Christoph Gohlke provides a major public good by hosting precompiled packages at

In my case I needed opencv which meant downloading and installing “‌exe”

Then in python import as usual “import cv”


If the package can’t find your winpython installation then you might not have registered it as described above.

If your installation of Spyder stops working, you may have to reset your PATH environmental variables. You can view and edit environmental variables more easily with a freeware program like Rapid Environment Editor. In my case, I had to uninstall all of my python installations and packages before it would start working again.

If you receive the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.

Then it probably means you have 64 bit python but a 32 bit version of your package. Either find a precompiled version that is listed as 64 bit or you’ll have to compile it yourself.


I am a political scientist working broadly within the field of security studies. Substantively, I study the causes and consequences of political violence. Methodologically, I specialize in using technology and quantitative methods to make available new sources of high resolution conflict data from archival documents, expert surveys, and large-scale crowdsourced mining of secondary sources.

I am currently a postdoctoral researcher at the University of California, San Diego with positions at the University of California Institute on Global Conflict and Cooperation (IGCC), the UCSD Department of Mathematics. I work closely with David Meyer and his group of mathematicians and computer scientists.

I received my PhD and MA in Politics from Princeton University and my BA in Government and History from the University of Texas at Austin.

Python 64 Bit on Windows Part 2, Building Packages

Building packages packages for 64 bit python is straightforward once you figure out the main steps.

First, download and set up the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 as explained here.

You have to execute the SDK’s command shell, which will have a shortcut in Start -> All Programs -> Microsoft Windows SDK v7.0 -> “CMD Shell”

Execute two commands in the shell to setup the environment

setenv /x64 /release

The color should turn green. Then as if it were a normal DOS box, navigate to the folder where you unzipped the package’s file and run the command “ install”

With any luck, the package will then install without error returning you to the command prompt.

Converting Military Grid Reference System Coordinates (MGRS)

Converting MGRS coordinates isn’t directly supported by most GIS applications since it’s not part of the popular PROJ.4 Cartographic Projections Library.

You can convert MGRS one at a time or in batch with GeoTrans.

There’s mgrs specific python wrapper for Geotrans  mgrs 1.1.0

Another alternative is  GeographicLib which has standalone utilities for converting MGRS along with other systems. It has wrappers in most languages, but the specific conversion function isn’t available in python.

Test blog post