<jupyter_start><jupyter_text>Elevation profiles extracted from SRTM over Mt Baker compared with ICESat-2<jupyter_code>import numpy as np
import geopandas as gpd
import rasterio
import matplotlib.pyplot as plt
import glob
from topolib import gda_lib
import topolib
import gdal<jupyter_output><empty_output><jupyter_text>Read reference DEM<jupyter_code># dem_fn = '/home/jovyan/data/srtm_elevation/SRTM3/cache/srtm_wa_subset.vrt'
# dem_fn = '/home/jovyan/data/baker_1_m/baker_2015_utm_m.vrt'
# dem = rasterio.open(dem_fn)<jupyter_output><empty_output><jupyter_text>Read ATL06 data<jupyter_code>data_dir = '/home/jovyan/data/nsidc/**/'
ATL06_list = sorted(glob.glob(data_dir + "*.h5"))<jupyter_output><empty_output><jupyter_text>Extract points from NED<jupyter_code>ATL06_fn = ATL06_list[0]
dataset_dict={'land_ice_segments':['h_li',
                                   'delta_time',
                                   'longitude',
                                   'latitude'],
              'land_ice_segments/ground_track':['x_atc']}

ATL06_gdf = gda_lib.ATL06_2_gdf(ATL06_fn,dataset_dict)
ATL06_gdf.head()
from pygeotools.lib import geolib
ned_elevs = []

lons = list(ATL06_gdf['longitude'].values)
lats = list(ATL06_gdf['latitude'].values)

len(lons)
len(ned_elevs)
%%capture
ned_elevs = geolib.get_HAE(lons[0],lats[0])
ned_elevs
# ATL06_gdf['NED_elev'] = ned_elevs
ATL06_gdf['NED_ATL06_diff'] = ATL06_gdf['NED_elev'] - glas_gdf_aea_rgi['h_li']
ATL06_gdf['longtitude'], ATL06_gdf['latitude']
ATL06_gdf['longtitude']
glas_df['geometry'] = glas_df['geometry'].apply(geolib.get_NED)
geolib.get_NED?<jupyter_output><empty_output><jupyter_text>Sample DEM at ICESat-2 ATL06<jupyter_code>ATL06_fn = ATL06_list[0]
dataset_dict={'land_ice_segments':['h_li',
                                   'delta_time',
                                   'longitude',
                                   'latitude'],
              'land_ice_segments/ground_track':['x_atc']}

ATL06_gdf = gda_lib.ATL06_2_gdf(ATL06_fn,dataset_dict)
ATL06_gdf = ATL06_gdf.to_crs(dem.crs)
poly = gda_lib.dem2polygon(dem_fn)
glas_gdf_aea_rgi = gpd.sjoin(ATL06_gdf, poly, op='intersects', how='inner')
points_xy = list(zip(glas_gdf_aea_rgi.geometry.x, glas_gdf_aea_rgi.geometry.y))

refdem_sample = []
for val in dem.sample(points_xy):
    refdem_sample.append(val[0])<jupyter_output><empty_output><jupyter_text>Plot data<jupyter_code>glas_gdf_aea_rgi['srtm_height'] = refdem_sample
glas_gdf_aea_rgi['diff'] = glas_gdf_aea_rgi['srtm_height'] - glas_gdf_aea_rgi['h_li']
fit,ax = plt.subplots(1,2)
ax[0].scatter(glas_gdf_aea_rgi.index, glas_gdf_aea_rgi['h_li'])
ax[1].scatter(glas_gdf_aea_rgi.index, glas_gdf_aea_rgi['srtm_height']);
glas_gdf_aea_rgi['diff'].plot(marker='.', linestyle='none');
glas_gdf_aea_rgi['diff'].mean()<jupyter_output><empty_output><jupyter_text>geoid offset<jupyter_code>glas_gdf_aea_rgi.total_bounds
fig,ax = plt.subplots()
im = ax.imshow(dem.read(1),cmap='inferno')
glas_gdf_aea_rgi.plot(ax=ax)
plt.colorbar(im,label='HAE (m WGS84)')
glas_df['geometry'] = glas_df['geometry'].apply(geolib.get_NED)
https://github.com/dshean/pygeotools.git
ds = gdal.Open('/home/jovyan/data/baker_1_m/baker_2015_dsm_7_wgs84-adj.tif')
ds = gdal.Translate('/home/jovyan/data/baker_1_m/baker_2015_dsm_7_wgs84-adj-sub.tif', ds, projWin = [-121.855968, 48.774327, -121.796142, 48.712009])
ds = None
%%bash
gdalwarp -r cubic -t_srs EPSG:4326 /home/jovyan/data/baker_1_m/baker_2015_dsm_7_m_utm-adj.tif /home/jovyan/data/baker_1_m/baker_2015_dsm_7_wgs84-adj.tif<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13927262475331265, 'fraction_numerical': 0.04059768818720045, 'mean_word_length': 5.347048300536673, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '65429', 'license': 'MIT', 'n_tokens_mistral': 1667, 'n_tokens_neox': 1572, 'n_words': 162, 'path': 'contributors/friedrich/NED_vs_ATL06.ipynb', 'repo_name': 'dlilien/topohack', 'size': '3547'}