title: Heat World Map with MatPlotLib
body: <p>I am trying to combine a heat map with a world map i created. What i got is a CSV file with 3 columns. The first column contains the name of a country and the second and third contain the latitude respectively the longitude. Now i wrote a class which plots the point according to this coordinates on a world map. That works fine but what i want now is a heat map, because having just a few points everything looks fine but i am going to have a great many of points. So depending on the count of points in a country and specified borders, the heat map should be realized.</p>
  
  <pre><code>import csv
  
  class toMap:
  
      def setMap(self):
          filename = 'log.csv'
          lats, lons = [], []
  
          with open(filename) as f:
              reader = csv.reader(f)
  
              next(reader)
  
              for row in reader:
                  lats.append(float(row[1]))
                  lons.append(float(row[2]))
  
          from mpl_toolkits.basemap import Basemap
          import matplotlib.pyplot as plt
          import numpy as np
  
          map = Basemap(projection='robin', resolution='l', area_thresh=1000.0,
                        lat_0=0, lon_0=-130)
          map.drawcoastlines()
          map.drawcountries()
          map.fillcontinents(color='gray')
          #map.bluemarble()
          #map.drawmapboundary()
          map.drawmeridians(np.arange(0, 360, 30))
          map.drawparallels(np.arange(-90, 90, 30))
  
          x, y = map(lons, lats)
          map.plot(x, y, 'ro', markersize=3)
  
          plt.show()
  
  def main():
      m = toMap()
      m.setMap()
  </code></pre>
  
  <p>Here is an example of what the CSV looks like:</p>
  
  <pre><code>Vietnam,10.35,106.35
  United States,30.3037,-97.7696
  Colombia,4.6,-74.0833
  China,35.0,105.0
  Indonesia,-5.0,120.0
  United States,38.0,-97.0
  United States,41.7511,-88.1462
  Bosnia and Herzegovina,43.85,18.3833
  United States,33.4549,-112.0777
  </code></pre>