【发布时间】:2021-08-09 16:58:30
【问题描述】:
我在新系统上安装了 Anaconda Spyder,我收到以下错误消息:
C:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py:973: 用户警告:透明度以字节表示的调色板图像应转换为 RGBA 图像 警告.warn(
下面是我正在使用的代码。
Python 3.8.8(默认,2021 年 4 月 13 日,15:08:03)[MSC v.1916 64 位 (AMD64)] 输入“copyright”、“credits”或“license”了解更多信息。
IPython 7.22.0 -- 增强的交互式 Python。
正在重启内核...
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy
import cartopy.io.img_tiles as cimgt
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
cartopy.config['pre_existing_data_dir']='C:/Users/***<USER>***/.local/share/cartopy'
mapSize = '10m'
zoom = 8
rivers = cfeature.NaturalEarthFeature('physical', 'rivers_lake_centerlines', mapSize)
states_provinces = cfeature.NaturalEarthFeature(category='physical',
name='admin_1_states_provinces_lines', scale=mapSize, facecolor='none')
request = cimgt.OSM()
stamen_terrain = cimgt.Stamen('terrain-background')
longMax = 126.38765
longMin = -132.80147
latMax = 54.03728
latMin = 34.90657
# Create a Stamen terrain background instance.
stamen_terrain = cimgt.Stamen('terrain-background')
fig = plt.figure(figsize=(90, 50))
ax = fig.add_subplot(1, 1, 1, projection=request.crs)
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth=2, color='gray',
alpha=0.5, linestyle='--')
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
gl.xlabel_style = {'size': 22, 'color': 'black', 'weight': 'bold'}
gl.ylabel_style = {'size': 22, 'color': 'black', 'weight': 'bold'}
# Limit the extent of the map to a small longitude/latitude range.
extent = [longMax, longMin, latMax, latMin]
ax.set_extent(extent, crs=ccrs.PlateCarree())
# Set the Stamen data zoom level
ax.add_image(stamen_terrain, zoom)
此错误/警告并不总是发生,但当它发生时,程序似乎冻结并且没有其他任何事情发生。即使我停止当前命令,也不会发生任何事情。我唯一能做的就是重启内核。
非常感谢任何帮助解决此问题。
【问题讨论】: