Skip to content

Instantly share code, notes, and snippets.

@smeschke
Last active August 17, 2016 20:57
Show Gist options
  • Select an option

  • Save smeschke/351a97dd8b0d81482817404d3c7b5e53 to your computer and use it in GitHub Desktop.

Select an option

Save smeschke/351a97dd8b0d81482817404d3c7b5e53 to your computer and use it in GitHub Desktop.

Revisions

  1. smeschke revised this gist Aug 3, 2016. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions geoplotting
    Original file line number Diff line number Diff line change
    @@ -30,10 +30,11 @@ while year < 2040: #iterate through years, mapping each temple
    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')
    if temple[2]==2016: m.plot(x, y, 'go', markersize=size, alpha=1, color='b')
    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))
  2. smeschke revised this gist Aug 3, 2016. No changes.
  3. smeschke created this gist Aug 3, 2016.
    45 changes: 45 additions & 0 deletions geoplotting
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    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')
    if temple[2]==2016: m.plot(x, y, 'go', markersize=size, alpha=1, color='b')
    temples_plotted += 1

    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