#########################################################
# Plotting points on Lambert Conformal projection with blue marble image
#
#
# JHPS
# C: 26/11/2013
#######################################################
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#Points
stops = pd.read_csv('stops.csv') #This is just a csv (e.g. excel) file with columns 'NAME', 'LON', and 'LAT'
num = 0 # num picks the element in the stops list that you want to plot (starting from 0)
lon_c = stops['LON'][num]
lat_c = stops['LAT'][num]
#Setup
fig = plt.figure()
#map = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
ax = fig.add_axes([0.1,0.1,0.8,0.8])
map = Basemap(llcrnrlon=lon_c - 60,llcrnrlat=30,urcrnrlon=lon_c + 60,urcrnrlat=70.000,\
rsphere=(6378137.00,6356752.3142),\
resolution='l',area_thresh=1000.,projection='lcc',\
lat_1=10.,lon_0=lon_c,ax=ax)
map.drawparallels(np.arange(-90.,91.,30.))
map.drawmeridians(np.arange(-180.,181.,60.))
parallels = np.arange(0.,80,20.)
map.drawparallels(parallels,labels=[1,0,0,1])
meridians = np.arange(10.,360.,30.)
map.drawmeridians(meridians,labels=[1,0,0,1])
map.bluemarble()
map.drawcountries(linewidth=1)
x,y = map(stops['LON'][1],stops['LAT'][1])
map.plot(x,y,'r.',markersize=20)
plt.show()
No comments:
Post a Comment