为什么 hexbin 网格在极坐标立体投影中失真

Why is hexbin grid distorted in polar stereo projection

我想了解为什么北极或南极立体投影中的 hexbin 图显示压扁的六边形,即使网格的面积是正方形且投影面积大致相等。

我已经尝试过使用底图进行北极和南极立体投影。

import numpy as np
from numpy.random import uniform
import matplotlib.pyplot as plt 
from mpl_toolkits.basemap import Basemap

fig = plt.figure(figsize=(12,10)) # width, height in inches
ax =fig.add_axes([-0.02,0.1,0.74,0.74]) 

m = Basemap(epsg='3413',lon_0=0.,resolution='l',width=6000000,height=6000000)

m.drawcoastlines()

m.drawmapscale(0.,90.,0.,90.,1000)

npts=2000
lats = uniform(60.,80.,size=npts)
lons = uniform(0.,360.,size=npts)
data = uniform(0.,4800.,size=npts)

x,y=m(lons, lats)

thiscmap=plt.cm.get_cmap('viridis')

p=m.hexbin(x,y,C=data,gridsize=[10,10],cmap=thiscmap)

plt.show()

我不知道你为什么得到 squashed hexagons。但是您可以通过设置适当的 gridsize 值来调整六边形形状。在这里我修改你的代码并获得更好的情节。

import numpy as np
from numpy.random import uniform
import matplotlib.pyplot as plt 
from mpl_toolkits.basemap import Basemap

fig = plt.figure(figsize=(12,10)) # width, height in inches
ax =fig.add_axes([-0.02, 0.1, 0.74, 0.74]) 

# North polar stereographic projection epsg='3413'; ***large areal distortion***
#m = Basemap(epsg='3413', lon_0=0., resolution='c', width=6000000, height=6000000)

# 'laea':  Lambert Azimuthal Equal Area
# Thematic mapping with ground surface data should be plotted on 'equal-area' projection
m = Basemap(projection='laea', lon_0=0., lat_0=90, resolution='l', width=6000000, height=6000000)

m.drawcoastlines(linewidth=0.5)

m.drawmapscale(0.,90.,0.,90.,1000)  # 1000 km?

npts = 2000
lats = uniform(60.,80.,size=npts)  # not cover N pole
lons = uniform(0.,360.,size=npts)  # around W to E
data = uniform(0.,4800.,size=npts)

x,y = m(lons, lats)

thiscmap = plt.cm.get_cmap('viridis')

# To get 'rounded' hexagons, gridsize should be specified appropriately
# need some trial and error to get them right
#p=m.hexbin(x, y, C=data, gridsize=[10,10], cmap=thiscmap)  # original code
m.hexbin(x, y, C=data, gridsize=[16,11], cmap=thiscmap)     # better

plt.colorbar()  # useful on thematic map

plt.show()

您使用的投影 (epsg:3413) 是立体投影,具有较大的区域畸变。在这种情况下,专题制图更合适的投影是 Lambert Azimuthal Equal Area.

结果图: