Created
January 24, 2020 18:08
-
-
Save jscarto/fe2aedc48ef6499dcbcb3fc9af09d527 to your computer and use it in GitHub Desktop.
Example: Reading GEDI Level 2A data in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# read file | |
file = 'GEDI02_A_2019138044926_O02428_T03843_02_001_01.h5' | |
f = h5py.File(file, 'r') | |
# get some variables for BEAM0000 (change to other beam/vars as needed) | |
elev = f['BEAM0000']['elev_highestreturn'][:] | |
lat = f['BEAM0000']['lat_highestreturn'][:] | |
lon = f['BEAM0000']['lon_highestreturn'][:] | |
# subset transect to specific range of lats | |
idx = np.where((lat >= 0.0) & (lat <= 21.0)) | |
elev = elev[idx[0][0]:idx[0][-1]] | |
lat = lat[idx[0][0]:idx[0][-1]] | |
lon = lon[idx[0][0]:idx[0][-1]] | |
# create a basic plot | |
plt.plot(lon, elev) | |
plt.show() | |
# create a data frame, write it to CSV for mapping in QGIS | |
df = pd.DataFrame({ | |
'lat': lat, | |
'lon': lon, | |
'elev': elev | |
}) | |
df.to_csv('gedi_out.csv', index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment