Python 在底图中绘制倾斜网格网络
下面是一个示例图作为说明 该图显示了欧洲部分地区的卫星SO2柱数据 由于卫星与经度的差异,符合卫星扫描原理的网格网络与经度不平行Python 在底图中绘制倾斜网格网络,python,matplotlib,matplotlib-basemap,Python,Matplotlib,Matplotlib Basemap,下面是一个示例图作为说明 该图显示了欧洲部分地区的卫星SO2柱数据 由于卫星与经度的差异,符合卫星扫描原理的网格网络与经度不平行 我不知道是否可以在matplotlib.basemap中使用pcolor或pcolormesh绘制这种网格网络。所以,我把我的问题贴在这里。看看本页的不同例子: 示例的主要思想是在底图上绘制pcolormesh: 查看本页中的不同示例: 示例的主要思想是在底图上绘制pcolormesh: 我偶然发现了这个问题,因为我也在寻找一种方法,使用matplotlib和bas
我不知道是否可以在matplotlib.basemap中使用pcolor或pcolormesh绘制这种网格网络。所以,我把我的问题贴在这里。看看本页的不同例子: 示例的主要思想是在底图上绘制pcolormesh:
查看本页中的不同示例: 示例的主要思想是在底图上绘制pcolormesh:
我偶然发现了这个问题,因为我也在寻找一种方法,使用matplotlib和basemap在地图上绘制网格卫星测量。 我不确定我的想法是否与你的问题相关,因为我的像素只能假设非常有限的离散值4,但我决定无论如何回答,也要看看你是否最终找到了一个有效的解决方案。我所做的是使用多边形方法,将每个像素直接绘制为地图上的多边形。 我将alpha值设置为基础物理测量的函数。在我的例子中——一个云遮罩图——这个策略非常有效。 下面是为要打印的每个像素调用的函数:
def draw_cloud_pixel(lats, lons, index, mapplot):
"""Draw a pixel on the map. The fill color alpha level depends on the cloud index,
ranging from 0.1 (almost fully transparent) for confidently clear pixels to 1 (fully opaque)
for confidently cloudy pixels.
Keyword arguments:
lats -- Array of latitude values for the pixel 4 corner points (numpy array)
lons -- Array of longitudes values for the pixel 4 corner points (numpy array)
index -- Cloud mask index for given pixel:
0: confidently_cloudy
1: probably_cloudy
2: probably_clear
3: confidently_clear
mapplot -- Map object for coordinate transformation
Returns:
None
"""
x, y = mapplot(lons, lats)
xy = zip(x,y)
poly = Polygon(xy, facecolor='white', alpha=1-0.3*index)
plt.gca().add_patch(poly)
在我的主绘图例程中,然后为选定区域中的每个像素调用draw_cloud_pixel函数:
# draw plot, each pixel at the time
for scanline in xrange(select_cp_lat.shape[0]):
for pixel in xrange(select_cp_lat.shape[1]):
draw_cloud_pixel(select_cp_lat[scanline, pixel,:],
select_cp_lon[scanline, pixel,:],
cloud_mask[scanline, pixel],
mapplot)
我得到这样的情节:
我偶然发现了这个问题,因为我也在寻找一种方法,使用matplotlib和basemap在地图上绘制网格卫星测量值。 我不确定我的想法是否与你的问题相关,因为我的像素只能假设非常有限的离散值4,但我决定无论如何回答,也要看看你是否最终找到了一个有效的解决方案。我所做的是使用多边形方法,将每个像素直接绘制为地图上的多边形。 我将alpha值设置为基础物理测量的函数。在我的例子中——一个云遮罩图——这个策略非常有效。 下面是为要打印的每个像素调用的函数:
def draw_cloud_pixel(lats, lons, index, mapplot):
"""Draw a pixel on the map. The fill color alpha level depends on the cloud index,
ranging from 0.1 (almost fully transparent) for confidently clear pixels to 1 (fully opaque)
for confidently cloudy pixels.
Keyword arguments:
lats -- Array of latitude values for the pixel 4 corner points (numpy array)
lons -- Array of longitudes values for the pixel 4 corner points (numpy array)
index -- Cloud mask index for given pixel:
0: confidently_cloudy
1: probably_cloudy
2: probably_clear
3: confidently_clear
mapplot -- Map object for coordinate transformation
Returns:
None
"""
x, y = mapplot(lons, lats)
xy = zip(x,y)
poly = Polygon(xy, facecolor='white', alpha=1-0.3*index)
plt.gca().add_patch(poly)
在我的主绘图例程中,然后为选定区域中的每个像素调用draw_cloud_pixel函数:
# draw plot, each pixel at the time
for scanline in xrange(select_cp_lat.shape[0]):
for pixel in xrange(select_cp_lat.shape[1]):
draw_cloud_pixel(select_cp_lat[scanline, pixel,:],
select_cp_lon[scanline, pixel,:],
cloud_mask[scanline, pixel],
mapplot)
我得到这样的情节: