Last active
August 17, 2016 20:57
-
-
Save smeschke/351a97dd8b0d81482817404d3c7b5e53 to your computer and use it in GitHub Desktop.
Plotting the Proliferation of Mormon Temples with Basemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.basemap import Basemap | |
import matplotlib.pyplot as plt | |
import csv | |
#get list of temple name, location, dedication data, lat, and lon | |
path = '/home/sm/Desktop/temple_data.csv' | |
temples = [] #create a list to store the temple data from the spread sheet | |
with open(path, 'rb') as csvfile: #open the csv file | |
temple_data = csv.reader(csvfile, delimiter=',', quotechar='"') #load temple data | |
for temple in temple_data: #iterate through data to change year to int | |
try: | |
year = int(temple[2][-4:]) | |
temples.append((temple[0],temple[1],year,temple[3],temple[4])) | |
except: temples.append((temple[0],temple[1],2016,temple[3],temple[4])) | |
#sort list by dedication date | |
temples = sorted(temples, key=lambda temple: temple[2]) | |
year = temples[0][2] - 10 #ten years before the earliest dedication date | |
while year < 2040: #iterate through years, mapping each temple | |
m = Basemap(projection='mill') #create map (m) | |
m.drawcoastlines() | |
#m.drawcountries() | |
#m.bluemarble() | |
print 'Year: ', year #print the year in the terminal (to monitor progress) | |
temples_plotted = 0 #let's count the number of temples on the map | |
for temple in temples: #check to see of each temple should be plotted | |
if temple[2] <= year: #if the temple was built | |
x, y = m(float(temple[4]), float(temple[3])) #interpolate coordinates | |
size = temple[2]-year+15 #more recently built temples are larger | |
if size<5: size=5 #minimum size is 5 | |
m.plot(x, y, 'go', markersize=size, alpha=1, color='r') #plot the temple on the map | |
if temple[2]==2016: m.plot(x, y, 'go', markersize=size, alpha=1, color='b') #future planned temples are blue | |
temples_plotted += 1 | |
#make the title | |
y = 2016 | |
if year < y: y = year | |
plt.text(0,0,' # of temples built:'+str(temples_plotted)) | |
plt.title('Mormon Temples built by year '+str(y)) | |
#plt.show() #show the map | |
plt.savefig('/home/sm/Desktop/mormon_img/'+str(year)+'.png') #save the map | |
plt.clf() #clear the plot | |
year+=1 #go to the next year and repeat |
-
Collect data from https://www.lds.org/church/temples/find-a-temple?lang=eng.
-
Copy and paste to a spread sheet, format. Title: temple_data. (there is a link to this spreadsheet above)
-
Use batch geocode (Google, 'batch geocode') to find lat and lon coordinates
-
Run python program.
-
Complile images into a .gif using the following terminal commands:
sudo apt-get install imagemagick
convert =delay 10 -loop0 *.png morman_gif.gif
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link to Mormon Temple Data