How to leave the oceans blank in the Basemap?

Asked

Viewed 40 times

0

The following code produces a map with a color scheme. I need the colors to stay only on the continents, leaving the oceans blank. How do I get this? excel file : https://docs.google.com/spreadsheets/d/1z3YCMyGRqX8q7TNC3w6BkDw2cuN2E0_P7W42syGmz7s/edit#gid=1183595729

dados=['meteo_model.xlsx']    #vai buscar os dados ao ficheiro excel
sheets=['Longitude (deg)','Latitude (deg)','Pressure (hPa)','Temperature (K)','qv (g kg^-1)','W (m s^-1)','V (m s^-1)','U (m s^-1)','Rain (mm)'
    ,'Elevation (m)']
nvar=len(sheets)
wb=pyxl.load_workbook(dados[0]) 


ivar=0 
for variable in sheets: 
ws=wb[variable]
if variable=='Longitude (deg)': 
    rows=ws.max_row        #identifica dimensao da worksheet
    cols=ws.max_column
    var=np.zeros((rows,cols,nvar))
for r in range(rows):
    for c in range(cols):
            var[r,c,ivar]=ws.cell(row=r+1,column=c+1).value        
ivar=ivar+1
lon=var[:,:,0];lat=var[:,:,1]; qv = var [:,:,3] - 273.15

plt.figure()
mymap = Basemap(height = 1.2e6, width = 1.2e6, resolution = 'l', area_thresh = 0.1, projection = 'tmerc',lon_0= -5,lat_0 = 40)
mymap.drawcoastlines(linewidth = 1)
mymap.drawmeridians(np.arange(0,360,5),labels = [False,False,False,True])
mymap.drawparallels(np.arange(-90,90,5),labels = [True,False,False,False])
x , y = mymap(lon,lat)



mymap = mymap.pcolormesh(x,y,qv,cmap='jet')
  • This in the Sopt, edit and translate your question!

  • My mistake, google automatically redirected me to Portuguese!

  • It’s done, thank you!

  • It would be interesting, and it would help the staff if you explain better where this your problem, if possible add an excerpt from the file meteo_model.xlsx, to test the code.. See: How to create a Minimum, Complete and Verifiable example

  • How to put an excel file here?

  • If possible copy some columns and add a link using Google Docs, etc..

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.