Пересечение Даты с cartopy.io.img_tiles - PullRequest
0 голосов
/ 04 апреля 2020

Я пытаюсь выяснить, как создать карту, которая пересекает линию даты с помощью Cartopy и ландшафта из img_tiles. Вот что у меня есть:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import cartopy.feature as cfeature
import cartopy.io.img_tiles as cimgt
import shapely.geometry as sgeom

my_dpi = 96
plt.figure(figsize=(1530/my_dpi, 900/my_dpi), dpi=my_dpi, frameon=False)
plt.subplots_adjust(left=0.0, right=1.0, top=1.0, bottom=0)
ax = plt.axes(projection=ccrs.Mercator(central_longitude=180))
terrain = cimgt.Stamen('terrain-background')
ax.add_image(terrain, 4)     
states = cfeature.NaturalEarthFeature('cultural', 'admin_1_states_provinces', '10m', edgecolor='darkblue',facecolor='none')
ax.add_feature(states, linewidth = 0.1, linestyle='-')

# draw box
box = sgeom.box(minx=69, maxx=210, miny=-57, maxy=13.5)
ax.add_geometries([box], ccrs.PlateCarree(), facecolor='coral', 
                   edgecolor='black', alpha=0.5)
# Set extent
ax.set_extent(oceania_coords,  crs=ccrs.PlateCarree())

plt.show()

Когда я рисую рамку вокруг области, которую я хочу увеличить, она выглядит правильно.

enter image description here

Когда я пытаюсь включить ax.set_extent в этом диапазоне, кажется, что все настройки установлены правильно, но все испорчено функциями img_tiles.

enter image description here

Есть ли способ обойти это? Спасибо за помощь!

1 Ответ

0 голосов
/ 04 апреля 2020

У меня есть достаточно подходящее решение, примыкающее к двум подсюжетам с соответствующей крысой ios и отключенными границами. На шве есть крошечный артефакт, но я в основном нарезаю океан в этом кадре, поэтому я в порядке. Когда у меня в кадре Россия, это становится более очевидным.

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import cartopy.feature as cfeature
import cartopy.io.img_tiles as cimgt
import shapely.geometry as sgeom
import matplotlib.gridspec as gridspec
my_dpi=96
f = plt.figure(figsize=(1530/my_dpi, 900/my_dpi), dpi=my_dpi, frameon=False)
spec = gridspec.GridSpec(ncols=2, nrows=1,width_ratios=[111,30])
plt.subplots_adjust(left=0.0, right=1.0, top=1.0, bottom=0)

ax1 = f.add_subplot(spec[0],projection=ccrs.Mercator(central_longitude=180))
terrain = cimgt.Stamen('terrain-background')
ax1.add_image(terrain, 3)
states = cfeature.NaturalEarthFeature('cultural', 'admin_1_states_provinces', '10m', edgecolor='darkblue',facecolor='none')
ax1.add_feature(states, linewidth = 0.1, linestyle='-')
ax1.set_extent([69, 180, -57, 13.5],  crs=ccrs.PlateCarree())
plt.gca().outline_patch.set_visible(False)

ax2 = f.add_subplot(spec[1],projection=ccrs.Mercator(central_longitude=180))
ax2.add_image(terrain, 3)
ax2.add_feature(states, linewidth = 0.1, linestyle='-')
ax2.set_extent([-180,-150, -57, 13.5],  crs=ccrs.PlateCarree())
plt.gca().outline_patch.set_visible(False)

plt.subplots_adjust(wspace=0)

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...