import s3fs
import fiona
import xarray as xr
import pandas as pd
import geopandas as gpd
import contextily as cx
import numpy as np
import matplotlib.pyplot as plt
import hvplot.xarray
import earthaccess
import warnings
warnings.filterwarnings("ignore", category=FutureWarning, module="earthaccess")
pd.set_option('display.max_columns', None) #make sure all columns displayed for shapefilesFrom the PO.DAAC Cookbook, to access the GitHub version of the notebook, follow this link.
SWOT Hydrology Dataset Exploration in the Cloud
Accessing and Visualizing SWOT Datasets
Requirement:
This tutorial can only be run in an AWS cloud instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via earthaccess python library; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region.
Learning Objectives:
- Access SWOT HR data prodcuts (archived in NASA Earthdata Cloud) within the AWS cloud, without downloading to local machine
- Visualize accessed data for a quick check
SWOT Level 2 KaRIn High Rate Version D Datasets:
River Vector Shapefile - SWOT_L2_HR_RIVERSP_D
Lake Vector Shapefile - SWOT_L2_HR_LAKESP_D
Water Mask Pixel Cloud NetCDF - SWOT_L2_HR_PIXC_D
Water Mask Pixel Cloud Vector Attribute NetCDF - SWOT_L2_HR_PIXCVec_D
Raster NetCDF - SWOT_L2_HR_Raster_D
Single Look Complex Data product - SWOT_L1B_HR_SLC_D
Notebook Author: Cassie Nickles, NASA PO.DAAC (Feb 2024) || Other Contributors: Zoe Walschots (PO.DAAC Summer Intern 2023), Catalina Taglialatela (NASA PO.DAAC), Luis Lopez (NASA NSIDC DAAC), Nicholas Tarpinian (NASA PO.DAAC) (Nov 2026)
Last updated: November 2026
Libraries Needed
Earthdata Login
An Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. If you don’t already have one, please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up. We use earthaccess to authenticate your login credentials below.
auth = earthaccess.login()Single File Access
1. River Vector Shapefiles
The s3 access link can be found using earthaccess data search. Since this collection consists of Reach and Node files, we need to extract only the granule for the Reach file. We do this by filtering for the ‘Reach’ title in the data link.
Alternatively, Earthdata Search (see tutorial) can be used to search in a map graphic user interface.
For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.
Search for the data of interest
#Retrieves granule from the day we want, in this case by passing to `earthdata.search_data` function the data collection shortname, temporal bounds, and filter by wildcards
river_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_RiverSP_D',
#temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
granule_name = '*Reach*_009_NA*') # here we filter by Reach files (not node), pass=009, continent code=NA
print(f"Found {len(river_results)} granules")Found 154 granules
Set up an s3fs session for Direct Cloud Access
s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.
fs_s3 = earthaccess.get_s3_filesystem(results=river_results)Create Fiona session to work with zip and embedded shapefiles in the AWS Cloud
The native format for this data is a .zip file, and we want the .shp file within the .zip file, so we will create a Fiona AWS session using the credentials from setting up the s3fs session above to access the shapefiles within the zip files. If we don’t do this, the alternative would be to download the data to the cloud environment (e.g. EC2 instance, user S3 bucket) and extract the .zip file there.
fiona_session=fiona.session.AWSSession(
aws_access_key_id=fs_s3.storage_options["key"],
aws_secret_access_key=fs_s3.storage_options["secret"],
aws_session_token=fs_s3.storage_options["token"]
)# Get the link for the first zip file
river_link = earthaccess.results.DataGranule.data_links(river_results[0], access='direct')[0]
# We use the zip+ prefix so fiona knows that we are operating on a zip file
river_shp_url = f"zip+{river_link}"
with fiona.Env(session=fiona_session):
SWOT_HR_shp1 = gpd.read_file(river_shp_url)
#view the attribute table
SWOT_HR_shp1 | reach_id | time | time_tai | time_str | p_lat | p_lon | river_name | wse | wse_u | wse_r_u | wse_c | wse_c_u | slope | slope_u | slope_r_u | slope2 | slope2_u | slope2_r_u | width | width_u | width_c | width_c_u | area_total | area_tot_u | area_detct | area_det_u | area_wse | d_x_area | d_x_area_u | layovr_val | node_dist | loc_offset | xtrk_dist | dschg_c | dschg_c_u | dschg_csf | dschg_c_q | dschg_gc | dschg_gc_u | dschg_gcsf | dschg_gc_q | dschg_m | dschg_m_u | dschg_msf | dschg_m_q | dschg_gm | dschg_gm_u | dschg_gmsf | dschg_gm_q | dschg_b | dschg_b_u | dschg_bsf | dschg_b_q | dschg_gb | dschg_gb_u | dschg_gbsf | dschg_gb_q | dschg_h | dschg_h_u | dschg_hsf | dschg_h_q | dschg_gh | dschg_gh_u | dschg_ghsf | dschg_gh_q | dschg_o | dschg_o_u | dschg_osf | dschg_o_q | dschg_go | dschg_go_u | dschg_gosf | dschg_go_q | dschg_s | dschg_s_u | dschg_ssf | dschg_s_q | dschg_gs | dschg_gs_u | dschg_gssf | dschg_gs_q | dschg_i | dschg_i_u | dschg_isf | dschg_i_q | dschg_gi | dschg_gi_u | dschg_gisf | dschg_gi_q | dschg_q_b | dschg_gq_b | reach_q | reach_q_b | dark_frac | ice_clim_f | ice_dyn_f | partial_f | n_good_nod | obs_frac_n | xovr_cal_q | geoid_hght | geoid_slop | solid_tide | load_tidef | load_tideg | pole_tide | dry_trop_c | wet_trop_c | iono_c | xovr_cal_c | n_reach_up | n_reach_dn | rch_id_up | rch_id_dn | p_wse | p_wse_var | p_width | p_wid_var | p_n_nodes | p_dist_out | p_length | p_maf | p_dam_id | p_n_ch_max | p_n_ch_mod | p_low_slp | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 72264000333 | -1.000000e+12 | -1.000000e+12 | no_data | 55.315605 | -67.347702 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 12582912 | 12582912 | 3 | 469762048 | -1.000000e+12 | 2 | -999 | 1 | -999 | -1.000000e+12 | 2 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1 | 1 | 72264000343, no_data, no_data, no_data | 72264000321, no_data, no_data, no_data | 435.000000 | 0.825536 | 855.5 | 1102092.164 | 74 | 521315.991 | 14834.719325 | -1.000000e+12 | 0 | 3 | 1 | 0 | LINESTRING (-67.39042 55.3669, -67.39015 55.36... |
| 1 | 72264000343 | -1.000000e+12 | -1.000000e+12 | no_data | 55.233872 | -67.322481 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 12582912 | 12582912 | 3 | 469762048 | -1.000000e+12 | 2 | -999 | 1 | -999 | -1.000000e+12 | 2 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1 | 1 | 72264000356, no_data, no_data, no_data | 72264000333, no_data, no_data, no_data | 438.500000 | 2.336040 | 246.0 | 30260.883 | 58 | 532845.343 | 11529.351945 | -1.000000e+12 | 0 | 2 | 1 | 0 | LINESTRING (-67.32944 55.27423, -67.32992 55.2... |
| 2 | 72264000383 | -1.000000e+12 | -1.000000e+12 | no_data | 55.418988 | -67.324170 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 12582912 | 12582912 | 3 | 469762048 | -1.000000e+12 | 2 | -999 | 1 | -999 | -1.000000e+12 | 2 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1 | 1 | 72264000391, no_data, no_data, no_data | 72264000371, no_data, no_data, no_data | 422.100006 | 0.050106 | 459.0 | 27392.684 | 13 | 503504.794 | 2635.751099 | -1.000000e+12 | 0 | 1 | 1 | 0 | LINESTRING (-67.34028 55.42479, -67.33981 55.4... |
| 3 | 72264000391 | -1.000000e+12 | -1.000000e+12 | no_data | 55.403506 | -67.298254 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 12582912 | 12582912 | 3 | 469762048 | -1.000000e+12 | 2 | -999 | 1 | -999 | -1.000000e+12 | 2 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1 | 1 | 72264000403, no_data, no_data, no_data | 72264000383, no_data, no_data, no_data | 425.700012 | 1.140955 | 80.0 | 730.703 | 11 | 505792.319 | 2287.524960 | -1.000000e+12 | 0 | 2 | 1 | 0 | LINESTRING (-67.31044 55.41074, -67.31007 55.4... |
| 4 | 72264000403 | -1.000000e+12 | -1.000000e+12 | no_data | 55.392786 | -67.267251 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 12582912 | 12582912 | 3 | 469762048 | -1.000000e+12 | 2 | -999 | 1 | -999 | -1.000000e+12 | 2 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1 | 1 | 72264000411, no_data, no_data, no_data | 72264000391, no_data, no_data, no_data | 425.899994 | 0.000000 | 473.0 | 12049.232 | 15 | 508703.871 | 2911.552644 | -1.000000e+12 | 0 | 2 | 1 | 0 | LINESTRING (-67.28395 55.40093, -67.28348 55.4... |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 886 | 73130000051 | 7.333829e+08 | 7.333829e+08 | 2023-03-29T05:28:24Z | 41.282059 | -73.086774 | Housatonic River | 1.868000e+00 | 1.391600e-01 | 1.061300e-01 | -1.000000e+12 | -1.000000e+12 | 4.434787e-04 | 4.164816e-05 | 4.153997e-05 | 2.776162e-04 | 1.759258e-05 | 1.733491e-05 | 1.832344e+02 | 2.184770e-01 | -1.000000e+12 | -1.000000e+12 | 2.453558e+06 | 2.796062e+03 | 3.154266e+05 | 2.796100e+03 | 2.185596e+05 | -1.000000e+12 | -1.000000e+12 | 1.505460e+01 | 8.185483e+01 | -2.613000e-02 | -5.925002e+04 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 8651192 | 8651192 | 2 | 532490 | 8.654912e-01 | 0 | -999 | 0 | 45 | 6.716418e-01 | 2 | -3.052420e+01 | 1.774357e-05 | -3.153961e-02 | -8.968345e-03 | -9.155393e-03 | 1.081965e-03 | -2.321656e+00 | -3.053715e-02 | -3.693802e-03 | 0.000000e+00 | 1 | 1 | 73130000064, no_data, no_data, no_data | 73130000043, no_data, no_data, no_data | 0.500000 | 1.188006 | 254.0 | 8895.093 | 67 | 21004.481 | 13390.267872 | -1.000000e+12 | 0 | 3 | 1 | 0 | LINESTRING (-73.1089 41.22987, -73.10875 41.23... |
| 887 | 73130000064 | 7.333829e+08 | 7.333829e+08 | 2023-03-29T05:28:24Z | 41.325029 | -73.103215 | Housatonic River | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1.989477e+02 | 3.043713e+00 | -1.000000e+12 | -1.000000e+12 | 7.165870e+04 | 1.096311e+03 | 5.298200e+04 | 1.096300e+03 | 4.985930e+04 | -1.000000e+12 | -1.000000e+12 | 0.000000e+00 | 7.599391e+01 | 4.719835e+01 | -6.195377e+04 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 29360570 | 29360570 | 3 | 167813130 | 2.606350e-01 | 0 | -999 | 1 | 0 | 0.000000e+00 | 2 | -3.040974e+01 | -1.000000e+12 | -3.144177e-02 | -8.923975e-03 | -9.131931e-03 | 1.081851e-03 | -2.320832e+00 | -3.026720e-02 | -3.687254e-03 | 0.000000e+00 | 1 | 1 | 73130000071, no_data, no_data, no_data | 73130000051, no_data, no_data, no_data | 4.100000 | 0.000000 | 279.0 | 2538.331 | 2 | 21364.670 | 360.188812 | -1.000000e+12 | 11118 | 1 | 1 | 0 | LINESTRING (-73.1011 41.32378, -73.10145 41.32... |
| 888 | 73130000071 | 7.333829e+08 | 7.333829e+08 | 2023-03-29T05:28:25Z | 41.356141 | -73.138446 | Housatonic River | 8.588300e+00 | 3.373900e-01 | 3.251700e-01 | -1.000000e+12 | -1.000000e+12 | -1.084051e-04 | 1.298321e-04 | 1.297974e-04 | -2.716161e-04 | 5.422293e-05 | 5.413987e-05 | 1.374031e+02 | 3.642860e-01 | -1.000000e+12 | -1.000000e+12 | 1.251205e+06 | 2.074120e+03 | 1.780066e+05 | 2.074100e+03 | 1.584147e+05 | -1.000000e+12 | -1.000000e+12 | 8.114700e+00 | 7.680998e+01 | -1.668424e+03 | -6.428824e+04 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 25428408 | 25428408 | 2 | 565250 | 7.724649e-01 | 0 | -999 | 1 | 17 | 3.695652e-01 | 2 | -3.037332e+01 | 1.114147e-05 | -3.136678e-02 | -8.886665e-03 | -9.102759e-03 | 1.080926e-03 | -2.319256e+00 | -3.006003e-02 | -3.684442e-03 | 0.000000e+00 | 1 | 1 | 73130000084, no_data, no_data, no_data | 73130000064, no_data, no_data, no_data | 7.300000 | 13.456961 | 137.0 | 4857.857 | 46 | 30470.754 | 9106.084579 | -1.000000e+12 | 0 | 2 | 1 | 0 | LINESTRING (-73.10498 41.3259, -73.10533 41.32... |
| 889 | 73130000084 | -1.000000e+12 | -1.000000e+12 | no_data | 41.382209 | -73.172231 | Housatonic River | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 12582912 | 12582912 | 3 | 469762048 | -1.000000e+12 | 0 | -999 | 1 | -999 | -1.000000e+12 | 2 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1 | 1 | 73130000091, no_data, no_data, no_data | 73130000071, no_data, no_data, no_data | 15.800000 | 6.547250 | 342.0 | 10522.698 | 2 | 30860.216 | 389.461298 | -1.000000e+12 | 763 | 2 | 1 | 0 | LINESTRING (-73.16973 41.38169, -73.17009 41.3... |
| 890 | 73130000091 | -1.000000e+12 | -1.000000e+12 | no_data | 41.428699 | -73.234695 | Housatonic River | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | 12582912 | 12582912 | 3 | 469762048 | -1.000000e+12 | 0 | -999 | 1 | -999 | -1.000000e+12 | 2 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 1 | 1 | 73130000104, no_data, no_data, no_data | 73130000084, no_data, no_data, no_data | 32.299999 | 3.342308 | 202.0 | 10469.706 | 82 | 47166.140 | 16305.923882 | -1.000000e+12 | 0 | 2 | 1 | 0 | LINESTRING (-73.17436 41.38295, -73.17465 41.3... |
891 rows × 127 columns
Quickly plot the SWOT river data
# Simple plot
fig, ax = plt.subplots(figsize=(10,7))
SWOT_HR_shp1.plot(ax=ax, color='black')
cx.add_basemap(ax, crs=SWOT_HR_shp1.crs, source=cx.providers.OpenTopoMap)
# # Another way to plot geopandas dataframes is with `explore`, which also plots a basemap
# SWOT_HR_shp1.explore()2. Lake Vector Shapefiles
The lake vector shapefiles can be accessed in the same way as the river shapefiles above.
For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.
Search for data of interest
lake_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_LakeSP_D',
#temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
granule_name = '*Prior*_009_NA*') # here we filter by files with 'Prior' in the name (This collection has three options: Obs, Unassigned, and Prior), pass #8 and continent code=NA
print(f"Found {len(lake_results)} granules")Found 158 granules
Set up an s3fs session for Direct Cloud Access
s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.
fs_s3 = earthaccess.get_s3_filesystem(results=lake_results)Create Fiona session to work with zip and embedded shapefiles in the AWS Cloud
The native format for this data is a .zip file, and we want the .shp file within the .zip file, so we will create a Fiona AWS session using the credentials from setting up the s3fs session above to access the shapefiles within the zip files. If we don’t do this, the alternative would be to download the data to the cloud environment (e.g. EC2 instance, user S3 bucket) and extract the .zip file there.
fiona_session=fiona.session.AWSSession(
aws_access_key_id=fs_s3.storage_options["key"],
aws_secret_access_key=fs_s3.storage_options["secret"],
aws_session_token=fs_s3.storage_options["token"]
)# Get the link for the first zip file
lake_link = earthaccess.results.DataGranule.data_links(lake_results[0], access='direct')[0]
# We use the zip+ prefix so fiona knows that we are operating on a zip file
lake_shp_url = f"zip+{lake_link}"
with fiona.Env(session=fiona_session):
SWOT_HR_shp2 = gpd.read_file(lake_shp_url)
#view the attribute table
SWOT_HR_shp2| lake_id | reach_id | obs_id | overlap | n_overlap | time | time_tai | time_str | wse | wse_u | wse_r_u | wse_std | area_total | area_tot_u | area_detct | area_det_u | layovr_val | xtrk_dist | ds1_l | ds1_l_u | ds1_q | ds1_q_u | ds2_l | ds2_l_u | ds2_q | ds2_q_u | quality_f | qual_f_b | dark_frac | ice_clim_f | ice_dyn_f | partial_f | xovr_cal_q | geoid_hght | solid_tide | load_tidef | load_tideg | pole_tide | dry_trop_c | wet_trop_c | iono_c | xovr_cal_c | lake_name | p_res_id | p_lon | p_lat | p_ref_wse | p_ref_area | p_date_t0 | p_ds_t0 | p_storage | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 7220021542 | no_data | no_data | no_data | no_data | -1.000000e+12 | -1.000000e+12 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -99999999 | -1.000000e+12 | 2 | -999 | -999 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | no_data | -99999999 | -68.330708 | 52.721181 | 617.445 | 0.010800 | 2024-06-15T18:00:40Z | 0.000002 | -1.000000e+12 | None |
| 1 | 7220021552 | no_data | no_data | no_data | no_data | -1.000000e+12 | -1.000000e+12 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -99999999 | -1.000000e+12 | 2 | -999 | -999 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | no_data | -99999999 | -68.334103 | 52.721129 | 617.351 | 0.018900 | 2024-06-15T18:00:40Z | 0.000003 | -1.000000e+12 | None |
| 2 | 7220021562 | no_data | no_data | no_data | no_data | -1.000000e+12 | -1.000000e+12 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -99999999 | -1.000000e+12 | 2 | -999 | -999 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | no_data | -99999999 | -67.761819 | 52.690249 | 631.347 | 0.078300 | 2024-06-15T18:00:43Z | -0.000000 | -1.000000e+12 | None |
| 3 | 7220021582 | no_data | no_data | no_data | no_data | -1.000000e+12 | -1.000000e+12 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -99999999 | -1.000000e+12 | 2 | -999 | -999 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | no_data | -99999999 | -68.193291 | 52.690610 | 633.731 | 0.025200 | 2024-06-15T18:00:41Z | 0.000001 | -1.000000e+12 | None |
| 4 | 7220021602 | no_data | no_data | no_data | no_data | -1.000000e+12 | -1.000000e+12 | no_data | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -999 | -99999999 | -1.000000e+12 | 2 | -999 | -999 | -999 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | no_data | -99999999 | -68.132815 | 52.686253 | 667.673 | 0.010800 | 2024-06-15T18:00:42Z | -0.000000 | -1.000000e+12 | None |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 78883 | 7240359082 | no_data | 724244R999971;724243R001135;724244R999970 | 97;0;0 | 3 | 7.333831e+08 | 7.333831e+08 | 2023-03-29T05:31:09Z | 4.207620e+02 | 2.210000e-01 | 1.500000e-02 | 3.156000e+00 | 1.744435e+01 | 1.214310e-01 | 1.577768e+01 | 1.214310e-01 | 6.400000e-02 | 4.141774e+04 | 1.322050e-01 | 3.241000e-03 | 9.519400e-02 | 3.212000e-03 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 3 | -99999999 | 9.554200e-02 | 2 | -999 | 0 | 2 | -2.319187e+01 | -2.614100e-02 | -4.164000e-03 | -4.989000e-03 | 1.380000e-03 | -2.192320e+00 | -4.135400e-02 | -2.471000e-03 | -1.000000e+12 | LAC CAPAOTIGAMAU;RIVIRE CAPAOTIGAMAU | -99999999 | -68.216947 | 50.312872 | 420.611 | 12.814200 | 2023-06-01T19:22:09Z | 0.002615 | -1.000000e+12 | MULTIPOLYGON (((-68.2699 50.2747, -68.27018 50... |
| 78884 | 7240504452 | no_data | 724245R999934;724245R000021 | 44;25 | 2 | 7.333831e+08 | 7.333831e+08 | 2023-03-29T05:31:19Z | 6.666110e+02 | 1.920000e-01 | 1.190000e-01 | 2.580000e-01 | 2.060390e-01 | 2.884000e-03 | 1.353340e-01 | 2.884000e-03 | -2.120000e-01 | 2.190530e+04 | -1.020000e-04 | 1.800000e-05 | -1.020000e-04 | 1.800000e-05 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 3 | -99999999 | 3.431590e-01 | 2 | -999 | 0 | 2 | -2.223558e+01 | -2.522600e-02 | -4.541000e-03 | -5.325000e-03 | 1.379000e-03 | -2.171283e+00 | -3.931600e-02 | -2.419000e-03 | -1.000000e+12 | no_data | -99999999 | -68.170181 | 50.909736 | 667.160 | 0.079200 | 2023-06-01T19:22:19Z | 0.000002 | -1.000000e+12 | MULTIPOLYGON (((-68.17019 50.90923, -68.17026 ... |
| 78885 | 7240515922 | no_data | 724246R999963;724246R000804 | 54;2 | 2 | 7.333831e+08 | 7.333831e+08 | 2023-03-29T05:31:34Z | 9.239560e+02 | 1.817000e+00 | 2.800000e-02 | 2.620300e+01 | 3.458763e+01 | 1.045840e-01 | 3.406329e+01 | 1.045840e-01 | 1.420000e-01 | 1.504974e+04 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 3 | -99999999 | 1.516000e-02 | 2 | -999 | 1 | 2 | -2.068857e+01 | -2.450200e-02 | -4.906000e-03 | -5.597000e-03 | 1.394000e-03 | -2.098231e+00 | -3.712600e-02 | -2.347000e-03 | -1.000000e+12 | no_data | -99999999 | -67.783947 | 51.702138 | 928.085 | 1.128600 | 2023-06-08T18:16:58Z | -0.000033 | -1.000000e+12 | MULTIPOLYGON (((-67.84121 51.6577, -67.84129 5... |
| 78886 | 7310142413 | 73114000603;73114000623;73114000573;7311400056... | 731233R000309;731233R999961 | 10;9 | 2 | 7.333830e+08 | 7.333830e+08 | 2023-03-29T05:29:28Z | 3.778470e+02 | 6.900000e-02 | 2.300000e-02 | 3.620000e-01 | 9.317694e+00 | 6.800300e-02 | 9.017757e+00 | 6.800300e-02 | 7.300000e-02 | 1.100610e+04 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 3 | -99999999 | 3.219000e-02 | 2 | -999 | 1 | 2 | -2.721679e+01 | -3.013800e-02 | -5.853000e-03 | -6.918000e-03 | 1.228000e-03 | -2.214899e+00 | -2.785200e-02 | -3.184000e-03 | -1.000000e+12 | UMBAGOG LAKE | 2087 | -71.042417 | 44.763517 | 379.008 | 30.457462 | 2024-05-17T22:56:44Z | 0.010775 | -1.000000e+12 | MULTIPOLYGON (((-71.03003 44.74691, -71.0294 4... |
| 78887 | 7310143403 | no_data | 731231R999958;731231R000404;731231R000387 | 88;0;0 | 3 | 7.333829e+08 | 7.333829e+08 | 2023-03-29T05:29:08Z | 1.525470e+02 | 4.000000e-03 | 1.000000e-03 | 2.530000e-01 | 1.642703e+02 | 4.670850e-01 | 9.523078e+01 | 4.670850e-01 | 1.200000e-02 | 2.072756e+04 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | -1.000000e+12 | 3 | -99999999 | 4.202800e-01 | 1 | -999 | 0 | 2 | -2.809886e+01 | -3.124700e-02 | -6.195000e-03 | -7.347000e-03 | 1.201000e-03 | -2.278929e+00 | -2.764700e-02 | -3.348000e-03 | -1.000000e+12 | BRICKYARD COVE;LAKE WINNIPESAUKEE | 2145 | -71.340440 | 43.614850 | 153.221 | 174.750008 | 2023-05-05T23:33:06Z | 0.045317 | -1.000000e+12 | MULTIPOLYGON (((-71.39814 43.58012, -71.3981 4... |
78888 rows × 52 columns
Quickly plot the SWOT lakes data
fig, ax = plt.subplots(figsize=(10,7))
SWOT_HR_shp2.plot(ax=ax, color='black')
cx.add_basemap(ax, crs=SWOT_HR_shp2.crs, source=cx.providers.OpenTopoMap)
Accessing the remaining files is different than the shp files above. We do not need to read the shapefiles within a zip file using something like Fiona session (or to download and unzip in the cloud) because the following SWOT HR collections are stored in netCDF files in the cloud. For the rest of the products, we will open via xarray, not geopandas.
3. Water Mask Pixel Cloud NetCDF
Search for data collection and time of interest
For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.
pixc_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_PIXC_D',
#granule_name = '*_009_*', # pass number 9 if we want to filter further
#temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX
print(f"Found {len(pixc_results)} granules")Found 280 granules
Open data using xarray
The pixel cloud netCDF files are formatted with three groups titled, “pixel cloud”, “tvp”, or “noise” (more detail here). In order to access the coordinates and variables within the file, a group must be specified when calling xarray open_dataset.
ds_PIXC = xr.open_mfdataset(earthaccess.open([pixc_results[0]]), group = 'pixel_cloud', engine='h5netcdf')
ds_PIXC<xarray.Dataset> Size: 658MB
Dimensions: (points: 2348113, complex_depth: 2,
num_pixc_lines: 3278)
Coordinates:
latitude (points) float64 19MB dask.array<chunksize=(469623,), meta=np.ndarray>
longitude (points) float64 19MB dask.array<chunksize=(469623,), meta=np.ndarray>
Dimensions without coordinates: points, complex_depth, num_pixc_lines
Data variables: (12/62)
azimuth_index (points) float64 19MB dask.array<chunksize=(782705,), meta=np.ndarray>
range_index (points) float64 19MB dask.array<chunksize=(782705,), meta=np.ndarray>
interferogram (points, complex_depth) float32 19MB dask.array<chunksize=(782705, 1), meta=np.ndarray>
power_plus_y (points) float32 9MB dask.array<chunksize=(782705,), meta=np.ndarray>
power_minus_y (points) float32 9MB dask.array<chunksize=(782705,), meta=np.ndarray>
coherent_power (points) float32 9MB dask.array<chunksize=(782705,), meta=np.ndarray>
... ...
pixc_line_qual (num_pixc_lines) float64 26kB dask.array<chunksize=(3278,), meta=np.ndarray>
pixc_line_to_tvp (num_pixc_lines) float32 13kB dask.array<chunksize=(3278,), meta=np.ndarray>
data_window_first_valid (num_pixc_lines) float64 26kB dask.array<chunksize=(3278,), meta=np.ndarray>
data_window_last_valid (num_pixc_lines) float64 26kB dask.array<chunksize=(3278,), meta=np.ndarray>
data_window_first_cross_track (num_pixc_lines) float32 13kB dask.array<chunksize=(3278,), meta=np.ndarray>
data_window_last_cross_track (num_pixc_lines) float32 13kB dask.array<chunksize=(3278,), meta=np.ndarray>
Attributes:
description: cloud of geolocated interferogram pixels
interferogram_size_azimuth: 3278
interferogram_size_range: 5623
looks_to_efflooks: 1.5509709858821588
num_azimuth_looks: 7.0
azimuth_offset: 7Simple plot of the results
# This could take a few minutes to plot
plt.scatter(x=ds_PIXC.longitude, y=ds_PIXC.latitude, c=ds_PIXC.height)
plt.colorbar().set_label('Height (m)')
4. Water Mask Pixel Cloud Vector Attribute NetCDF
Search for data of interest
pixcvec_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_PIXCVec_D',
#granule_name = '*_009_*', # pass number 9 if we want to filter further
#temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX
print(f"Found {len(pixcvec_results)} granules")Found 302 granules
Open data using xarray
ds_PIXCVEC = xr.open_mfdataset(earthaccess.open([pixcvec_results[0]]), decode_cf=False, engine='h5netcdf')
ds_PIXCVEC<xarray.Dataset> Size: 183MB
Dimensions: (points: 2348113, nchar_reach_id: 11,
nchar_node_id: 14, nchar_lake_id: 10,
nchar_obs_id: 13)
Dimensions without coordinates: points, nchar_reach_id, nchar_node_id,
nchar_lake_id, nchar_obs_id
Data variables:
azimuth_index (points) int32 9MB dask.array<chunksize=(2348113,), meta=np.ndarray>
range_index (points) int32 9MB dask.array<chunksize=(2348113,), meta=np.ndarray>
latitude_vectorproc (points) float64 19MB dask.array<chunksize=(1174057,), meta=np.ndarray>
longitude_vectorproc (points) float64 19MB dask.array<chunksize=(1174057,), meta=np.ndarray>
height_vectorproc (points) float32 9MB dask.array<chunksize=(2348113,), meta=np.ndarray>
reach_id (points, nchar_reach_id) |S1 26MB dask.array<chunksize=(1174057, 6), meta=np.ndarray>
node_id (points, nchar_node_id) |S1 33MB dask.array<chunksize=(1174057, 7), meta=np.ndarray>
lake_id (points, nchar_lake_id) |S1 23MB dask.array<chunksize=(1174057, 5), meta=np.ndarray>
obs_id (points, nchar_obs_id) |S1 31MB dask.array<chunksize=(1174057, 7), meta=np.ndarray>
ice_clim_f (points) int8 2MB dask.array<chunksize=(2348113,), meta=np.ndarray>
ice_dyn_f (points) int8 2MB dask.array<chunksize=(2348113,), meta=np.ndarray>
Attributes: (12/46)
Conventions: CF-1.7
title: Level 2 KaRIn high rate pixel cloud vect...
short_name: L2_HR_PIXCVec
institution: JPL
source: Ka-band radar interferometer
history: 2025-10-30T22:28:34.150738Z: Creation
... ...
xref_prior_lake_db_file: SWOT_LakeDatabase_Nom_412_20000101T00000...
xref_reforbittrack_files: SWOT_RefOrbitTrackTileBoundary_Nom_20000...
xref_param_l2_hr_laketile_file: SWOT_Param_L2_HR_LakeTile_20000101T00000...
ellipsoid_semi_major_axis: 6378137.0
ellipsoid_flattening: 0.0033528106647474805
is_complete: TrueSimple plot
pixcvec_htvals = ds_PIXCVEC.height_vectorproc.compute()
pixcvec_latvals = ds_PIXCVEC.latitude_vectorproc.compute()
pixcvec_lonvals = ds_PIXCVEC.longitude_vectorproc.compute()
#Before plotting, we set all fill values to nan so that the graph shows up better spatially
pixcvec_htvals[pixcvec_htvals > 15000] = np.nan
pixcvec_latvals[pixcvec_latvals < 1] = np.nan
pixcvec_lonvals[pixcvec_lonvals > -1] = np.nanplt.scatter(x=pixcvec_lonvals, y=pixcvec_latvals, c=pixcvec_htvals)
plt.colorbar().set_label('Height (m)')
5. Raster NetCDF
Search for data of interest
For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.
raster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_D',
#temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
granule_name = '*100m*', # here we filter by files with '100m' in the name (This collection has two resolution options: 100m & 250m)
bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX
print(f"Found {len(raster_results)} granules")Found 1188 granules
Open data with xarray
ds_raster = xr.open_mfdataset(earthaccess.open([raster_results[0]]), engine='h5netcdf')
ds_raster<xarray.Dataset> Size: 602MB
Dimensions: (y: 1752, x: 1753)
Coordinates:
* y (y) float64 14kB 7.153e+06 7.153e+06 ... 7.328e+06
* x (x) float64 14kB 4.731e+05 4.732e+05 ... 6.483e+05
Data variables: (12/39)
crs object 8B ...
longitude (y, x) float64 25MB dask.array<chunksize=(584, 585), meta=np.ndarray>
latitude (y, x) float64 25MB dask.array<chunksize=(584, 585), meta=np.ndarray>
wse (y, x) float32 12MB dask.array<chunksize=(876, 877), meta=np.ndarray>
wse_qual (y, x) float32 12MB dask.array<chunksize=(1752, 1753), meta=np.ndarray>
wse_qual_bitwise (y, x) float64 25MB dask.array<chunksize=(876, 877), meta=np.ndarray>
... ...
load_tide_fes (y, x) float32 12MB dask.array<chunksize=(876, 877), meta=np.ndarray>
load_tide_got (y, x) float32 12MB dask.array<chunksize=(876, 877), meta=np.ndarray>
pole_tide (y, x) float32 12MB dask.array<chunksize=(876, 877), meta=np.ndarray>
model_dry_tropo_cor (y, x) float32 12MB dask.array<chunksize=(876, 877), meta=np.ndarray>
model_wet_tropo_cor (y, x) float32 12MB dask.array<chunksize=(876, 877), meta=np.ndarray>
iono_cor_gim_ka (y, x) float32 12MB dask.array<chunksize=(876, 877), meta=np.ndarray>
Attributes: (12/49)
Conventions: CF-1.7
title: Level 2 KaRIn High Rate Raster Data Product
institution: JPL
source: Ka-band radar interferometer
history: 2025-11-06T07:14:59Z : Creation
platform: SWOT
... ...
utm_zone_num: 60
mgrs_latitude_band: W
x_min: 473100.0
x_max: 648300.0
y_min: 7153200.0
y_max: 7328300.0Quick interactive plot with hvplot
ds_raster.wse.hvplot.image(y='y', x='x')6. SLC
Search for data collection and time of interest
For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.
slc_results = earthaccess.search_data(short_name = 'SWOT_L1B_HR_SLC_D',
#temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
#granule_name = '*_009_*', # here we can additionally filter by pass number 009
bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX
print(f"Found {len(slc_results)} granules")Found 275 granules
Open data using xarray
The L1B_HR_SLC product file contains five NetCDF data group called the slc, xfactor, noise, tvp, and grdem groups. More info can be found in the product description document within the dataset table for each group.
ds_SLC = xr.open_mfdataset(earthaccess.open([slc_results[0]]), group = 'slc', engine='h5netcdf')
ds_SLC<xarray.Dataset> Size: 2GB
Dimensions: (num_lines: 22956, num_pixels: 5623, complex_depth: 2)
Dimensions without coordinates: num_lines, num_pixels, complex_depth
Data variables:
slc_plus_y (num_lines, num_pixels, complex_depth) float32 1GB dask.array<chunksize=(3280, 804, 1), meta=np.ndarray>
slc_minus_y (num_lines, num_pixels, complex_depth) float32 1GB dask.array<chunksize=(3280, 804, 1), meta=np.ndarray>
slc_qual (num_lines) float32 92kB dask.array<chunksize=(22956,), meta=np.ndarray>
Attributes:
description: Single look complex images for plus_y and minus_y channels