def plot_basemap(latitude, longitude, image, color_palette=None):
# define basemap, color palette
cmap, tiler = get_map_params(image, color_palette)
# Find min/max coordinates to set extent
lat_0, lat_1, lon_0, lon_1 = get_max_extent(latitude, longitude)
# Automatically focus resolution
max_span = max((abs(lat_1) - abs(lat_0)), (abs(lon_1) - abs(lon_0)))
res = int(-1.4 * math.log1p(max_span) + 13)
# initiate tiler projection
ax = plt.axes(projection=tiler.crs)
# Define extents of any plotted data
ax.set_extent((lon_0, lon_1, lat_0, lat_1), ccrs.Geodetic())
# add terrain background
ax.add_image(tiler, res)
return ax, cmap
评论列表
文章目录