I have some physical data in raster as a numpy array (electromagnetic field density). I know latitude, longitude of its corners and pixel size. I know how to combine my raster with Basemap plot by converting coordinates from lat,lon to x,y point by point, but it takes too much time because there are more then 10k points in array. So, is there another way to plot my data on Basemap?
0
votes
1 Answers
1
votes
width = 200
height = 300
lllon, lllat, urlon, urlat = -144.99499512, -59.95500183, -65.03500366, 60.00500107
dlon = (urlon-lllon) / width
dLat = (urlat-lllat) / height
baseArray = np.fromfunction(lambda y,x: (1000.0 / (width + height)) * (y+x), (height, width), dtype = float)
lons = np.arange(lllon, urlon, dlon)
lats = np.arange(lllat, urlat, dLat)
lons, lats = np.meshgrid(lons, lats)
fig = plt.figure()
plt.title("The Plot")
m = Basemap(projection='cyl',
resolution = 'c',
llcrnrlon = lllon, llcrnrlat = lllat,
urcrnrlon =urlon, urcrnrlat = urlat
)
m.pcolormesh(lons, lats, baseArray, shading='flat', latlon=True)
plt.show()