我有一个脚本打印出墨西哥地图上有数据,我需要在地图上添加数千个点。我有一个.xyz文件中的所有点(长,纬,点#),我认为有一个非常直接的方法来做到这一点,但我还没有弄清楚。我已将此.xyz文件转换为.csv文件,假设这是必要的。
以下是.xyz文件的摘录。
-103.4855194092,25.5515251160,3
-103.4993667603,25.5775527954,4
-103.5101470947,25.6047039032,5
-103.5209426880,25.6318778992,6
-103.5317306519,25.6590518951,7
-103.5425415039,25.6862201691,8
-103.5533523560,25.7133903503,9
-103.5641708374,25.7405548096,10
这是脚本(day1.py),用我的数据打印出墨西哥地图。
#!\usr\bin\env python
from mexico import *
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
import numpy
import time
from datetime import datetime
from datetime import timedelta
# use low resolution coastlines.
# don't plot features that are smaller than 2000 square km.
map = Basemap(width=2800000, height=2200000, projection='lcc', resolution='l', area_thresh=2000, lat_1=45, lat_2=55, lat_0=25, lon_0=-103)
#map.bluemarble()
# draw coastlines, country boundaries, fill continents.
map.drawcoastlines(linewidth=0.5)
map.drawcountries(linewidth=0.5)
map.drawstates(linewidth=0.5)
map.fillcontinents(color = 'white')
# draw the edge of the map projection region (the projection limb)
map.drawmapboundary()
date = datetime.now()
date1 = date + timedelta(days=1)
for c in cities :
c.retrieveTemps()
long, lat = c.long, c.lat
x, y = map(float(long), float(lat))
if int(c.high0) >= 34:
plt.text(x, y, int(c.high0), fontsize=7, fontweight='bold')
if int(c.low0) <=3:
plt.text(x, y, int(c.low0), fontsize=7, fontweight='bold')
plt.title('Period 1: %s Critical Temperatures' % date1.strftime('%A'), fontsize=14, fontweight='bold')
plt.show()
所以在这个脚本中我需要添加一些东西来绘制.xyz文件中的所有点。任何想法或建议将不胜感激。谢谢!