欢迎光临散文网 会员登陆 & 注册

ICESat-2数据读取显示

2021-09-24 17:11 作者:我是水怪的哥  | 我要投稿

ICESat-2(Ice,Cloud and Land Elevation Satellite 2)卫星是NASA地球观测系统的组成之一,其于2018年9月15号发射。主要是测量冰盖高程、海冰的厚度以及陆地的地形。

其发布的数据产品有ATL02至ATL21等产品,平时需要根据不同的用途选择对应的数据产品。主要的数据类型见下表:

下面我将读取ATL08的数据,采用了python程序。

import icepyx as ipx
import numpy as np
import xarray as xr
import pandas as pd
import h5py
import os,json
from pprint import pprint
import dask.dataframe as dd
# put the full filepath to a data file here. You can get this in JupyterHub by navigating to the file,
# right clicking, and selecting copy path. Then you can paste the path in the quotes below.
fname = r'./dataset/ATL08_20210601183700_10531105_004_01.h5'
def read_atl08(fname, bbox=None):
   """
   Read 1 ATL08 file and output 6 reduced files.

   Extract variables of interest and separate the ATL08 file
   into each beam (ground track) and ascending/descending orbits.
   """
   # Each beam is a group
   group = ['/gt1l', '/gt1r', '/gt2l', '/gt2r', '/gt3l', '/gt3r']
   # Loop trough beams
   for k,g in enumerate(group):
       #-----------------------------------#
       # 1) Read in data for a single beam #
       #-----------------------------------#
       # Load variables into memory (more can be added!)
       with h5py.File(fname, 'r') as fi:
           lat = fi[g+'/land_segments/latitude'][:]
           lon = fi[g+'/land_segments/longitude'][:]
           canopy_h_metrics = fi[g+'/land_segments/canopy/canopy_h_metrics'][:]
           canopy_openness = fi[g+'/land_segments/canopy/canopy_openness'][:]
           h_canopy_quad = fi[g+'/land_segments/canopy/h_canopy_quad'][:]
       #---------------------------------------------#
       # 2) Filter data according region and quality #
       #---------------------------------------------#
       # Select a region of interest
       if bbox:
           lonmin, lonmax, latmin, latmax = bbox
           bbox_mask = (lon >= lonmin) & (lon <= lonmax) & \
                       (lat >= latmin) & (lat <= latmax)
       else:
           bbox_mask = np.ones_like(lat, dtype=bool)  # get all
       # Test for no data
       if len(canopy_h_metrics) == 0: continue
       #-----------------------#
       # 4) Save selected data #
       #-----------------------#
       # Define output file name
       ofile = fname.replace('.h5', '_'+g[1:]+'.h5')
       # Save variables
       with h5py.File(ofile, 'w') as f:
           f['lon'] = lon
           f['lat'] = lat
           f['canopy_h_metrics'] = canopy_h_metrics
           f['canopy_openness'] = canopy_openness
           f['h_canopy_quad'] = h_canopy_quad
           print('out ->', ofile)
       # save as csv
       ofilecsv = fname.replace('.h5', '_'+g[1:]+'.csv')
       result = pd.DataFrame()
       result['lon'] = lon
       result['lat'] = lat
       result['canopy_h_metrics_0'] = canopy_h_metrics[:,0]
       result['canopy_h_metrics_1'] = canopy_h_metrics[:,1]
       result['canopy_h_metrics_2'] = canopy_h_metrics[:,2]
       result['canopy_h_metrics_3'] = canopy_h_metrics[:,3]
       result['canopy_h_metrics_4'] = canopy_h_metrics[:,4]
       result['canopy_h_metrics_5'] = canopy_h_metrics[:,5]
       result['canopy_h_metrics_6'] = canopy_h_metrics[:,6]
       result['canopy_h_metrics_7'] = canopy_h_metrics[:,7]
       result['canopy_h_metrics_8'] = canopy_h_metrics[:,8]
       result['canopy_openness'] = canopy_openness
       result['h_canopy_quad'] = h_canopy_quad

       print('out ->', ofilecsv)
       result.to_csv(ofilecsv,index=None)
read_atl08(fname, None)

程序运行的结果将会以CSV的格式导出。

接着在arcgis中展示数据的空间分布:

另外分享一个网址,大家可以找到不同语言编写的数据读取代码,可以自己下载源程序调试读取;

https://hdfeos.org/zoo/index_openICESat2_Examples.php#ATL

下图是使用其中的代码绘制的效果

如有不对的地方,欢迎与我交流!

ICESat-2数据读取显示的评论 (共 条)

分享到微博请遵守国家法律