Every liquor store in Texas, mapped

Using python (with Pandas), the Google Maps Geocoding service, GeoJSON, and the Google Maps javascript API I created a map of all licensed Texas liquor stores as of December 2016.  Mapping all 2,547 individual points as markers on Google Maps is possible, but gets quite cluttered.  Alternatively, we can express this data in a heatmap layer.  Data source is the Texas Alcoholic Beverage Commision (TABC).

Full screen version here.

A python script was developed to interface with Google’s geocoding service to cycle through and find latitude/longitude based on address for each licensed location.  In some cases, the address on file with the TABC didn’t play nice with Google and had to be tweaked a little bit manually to find something that worked. As a result, a few of these points are likely slightly off from actual location but the vast majority are complete accurate to the street address level.

Once geocoded, selected fields (lat/lng, Name, Cleaned address, Owner’s name) were exported to a GeoJSON file via python’s Pandas module.  The GeoJSON was then imported as a data layer in to the Google maps api.  Most of this process follows Sev Leonard’s excellent tutorial here.  Alternatively, I could have defined an array of lat/lng points within the javascript file itself and generated markers from them – this probably would result in speed improvements but doesn’t have the flexibility that GeoJSON provides.

Lastly, I cycled through the points in the datalayer to create a matching set of points in a heatmap layer via the visualization library. A toggle button was added to allow switching back and forth between the heatmap and individual point layer. The toggle has a little bit of delay due to the large number of datapoints involved.

We’ll use this dataset for some additional analysis in future posts.

Leave a Reply

Your email address will not be published. Required fields are marked *