好奇心Log 发表于 2024-4-3 00:36:53

cartoee!轻量级地图可视化绘制利器!很好用.

本帖最后由 好奇心Log 于 2024-4-3 00:40 编辑

cartoee-小体积出版级地图可视化绘制
这段时间给我们的课程新增了很多「空间」和「统计」可视化新案例,详细可查阅:这图这么多人问!?赶紧给大家复现出来~~

在这个过程中发现一个好用的轻量级的出版级地图可视化图表绘制工具-「cartoee」,下面就给大家介绍一下:

「cartoee介绍」
cartoee 是一个简单的 Python 软件包,用于使用 Cartopy 将Google Earth Engine的结果制作成具有出版质量的地图,而无需将结果从Google Earth Engine引擎导出。

该软件包的目标只有一个:将Earth Engine引擎的处理结果转化为具有出版质量的制图界面。Cartoee 只需从Earth Engine引擎获取结果,并用正确的地理投影绘制出来,而更多的处理和可视化工作则由ee和cartopy完成。

PS:Google Earth Engine是一个专门处理卫星图像和其他地球观测数据云端运算平台。

1.安装方式:
pip install cartoee
「cartoee可视化案例」

导入包:
import ee
import cartoee as cee
import cartopy.crs as ccrs

# get an earth engine image
srtm = ee.Image("CGIAR/SRTM90_V4")
visualization = {'min':-500,'max':3000,'bands':'elevation'}
bbox = [-180,-90,180,90]
# plot the result using cartoee
ax = cee.getMap(srtm,region=bbox,visParams=visualization)

ax.coastlines()
plt.show()
Plotting an EE Image on a map
from cartopy.mpl.gridliner import LATITUDE_FORMATTER, LONGITUDE_FORMATTER

# plot the map
ax = cee.getMap(srtm,cmap='terrain',region=bbox,visParams=visualization)
# add a color bar using cartoee
cb = cee.addColorbar(ax,loc='right',cmap='terrain',visParams=visualization)

ax.coastlines()

# set gridlines and spacing
xticks = [-180,-120,-60,0,60,120,180]
yticks = [-90,-60,-30,0,30,60,90]
ax.gridlines(xlocs=xticks, ylocs=yticks,linestyle='--')

# set custom formatting for the tick labels
ax.xaxis.set_major_formatter(LONGITUDE_FORMATTER)
ax.yaxis.set_major_formatter(LATITUDE_FORMATTER)

# set tick labels
ax.set_xticks([-180,-120,-60, 0, 60, 120, 180], crs=ccrs.PlateCarree())
ax.set_yticks([-90, -60, -30, 0, 30, 60, 90], crs=ccrs.PlateCarree())

plt.show()Customizing maps# specify new region over Colorado
# showing the Great Continental Divide that splits the state
newRegion = [-111,35,-100,43]

ax = cee.getMap(srtm,cmap='terrain',region=newRegion,visParams=visualization,
               dims=2000)

# add a colorbar to our map
cb = cee.addColorbar(ax,loc='right',cmap='terrain',visParams=visualization)

# add a marker for Denver,CO
ax.plot(-104.9903,39.7392,'ko')
ax.text(-104.9,39.78,'Denver,CO')

plt.show()
https://cartoee.readthedocs.io/en/latest/examples/cartoee_simple.html#:~:text=our%20EE%20image.-,Plotting%20a%20specific%20region,-A%20lot%20of
「cartoee不同投影可视化案例:」

基础样式
ccrs.Mollweide()
ccrs.InterruptedGoodeHomolosine()
ccrs.Orthographic()
「Colorbar样式:」Colorbar positioning

「多子图绘制:」
# set up a blank map with multiple subplots
fig,ax = plt.subplots(ncols=2,nrows=2,figsize=(10,7),
                      subplot_kw={'projection': ccrs.Orthographic(-80,35)})

# format images and subplot titles with same dimensions as subplots
imgs = np.array([,])
titles = np.array([['DJF','MAM'],['JJA','SON']])

for i in range(len(imgs)):
    for j in range(len(imgs)):
      ax = cee.addLayer(imgs,ax=ax,
                               region=bbox,dims=500,
                               visParams=ndviVis,cmap='YlGn'
                              )
      ax.coastlines()
      ax.gridlines(linestyle='--')
      ax.set_title(titles)

plt.tight_layout()

cax = fig.add_axes()
cb = cee.addColorbar(ax,cax=cax,cmap='YlGn',visParams=ndviVis)

plt.show()
Multiple maps using subplots
局部地图
更多关于cartoee包的语法和可视化案例,可参考:cartoee包官网

文章来源于微信公众号:好奇心Log
页: [1]
查看完整版本: cartoee!轻量级地图可视化绘制利器!很好用.