0

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?

1 Answer 1

1
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()
Sign up to request clarification or add additional context in comments.

1 Comment

That's the way I do it. Creating the color mesh seems to be fast but the display is awfully slow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.