У меня есть эта проблема, когда я пытаюсь поставить спутниковую картинку выше basemap
. Может кто-нибудь помочь мне поставить спутниковую картинку выше basemap
?
Код:
import os
os.environ['PROJ_LIB'] = r'C:\Users\mateu\anaconda3\Library\share\proj'
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
from netCDF4 import Dataset
ncd_file = Dataset('C:/Users/mateu/Desktop/python aula/S5P_OFFL_L2__NO2____20200108T153448_20200108T171618_11595_01_010302_20200110T083056.nc', 'r')
lat = ncd_file.groups['PRODUCT'].variables['latitude'][0, :, :]
lon = ncd_file.groups['PRODUCT'].variables['longitude'][0, :, :]
no2_data = ncd_file.groups['PRODUCT'].variables['nitrogendioxide_tropospheric_column'][0, :, :]
fill_value = ncd_file.groups['PRODUCT'].variables['nitrogendioxide_tropospheric_column']._FillValue
fill_val = fill_value*1000000
no2_em = np.array(no2_data)*1000000
no2_em[no2_em == fill_val] = np.nan
no2_data = no2_em
from matplotlib.patches import Polygon
def make_map():
fig, ax = plt.subplots()
m = Basemap(projection='merc', llcrnrlat=-35, urcrnrlat=7,
llcrnrlon=-77, urcrnrlon=-32, resolution='l')
m.ax = ax
m.fillcontinents()
return fig, m
def drawstates(ax, shapefile=r'C:\Users\mateu\Desktop\python aula\i3geomap_limitesmunicipais'):
shp = m.readshapefile(shapefile, 'states', drawbounds=True)
for nshape, seg in enumerate(m.states):
poly = Polygon(seg, facecolor='0.75', edgecolor='k')
ax.add_patch(poly)
cmap = plt.cm.get_cmap('jet')
cmap.set_under('w')
m.pcolormesh(lon, lat, no2_data, latlon = True, vmin = 0 , vmax = 100, cmap = cmap)
fig, m = make_map()
drawstates(m.ax)