asf_search is an open source Python package for searching and downloading SAR data from ASF. This notebook demonstrates how to search and download NISAR GCOV data with asf_search.
Overview¶
1. Prerequisites¶
| Prerequisite | Importance | Notes |
|---|---|---|
| The software environment for this cookbook must be installed | Necessary |
Rough Notebook Time Estimate: 3 minutes
2. Search and download example¶
Search and download GCOV data with asf_search
2a. Search for GCOV data with asf_search.search()¶
import os
import asf_search as asf
from datetime import datetime
from getpass import getpass
session = asf.ASFSession()
session.auth_with_creds(input('EDL Username'), getpass('EDL Password'))
start_date = datetime(2025, 11, 22)
end_date = datetime(2025, 12, 5)
area_of_interest = "POLYGON((40.9131 12.3904,41.8891 12.3904,41.8891 13.2454,40.9131 13.2454,40.9131 12.3904))" # POINT or POLYGON as WKT (well-known-text)
opts=asf.ASFSearchOptions(**{
"maxResults": 250,
"intersectsWith": area_of_interest,
"start": start_date,
"end": end_date,
"processingLevel": [
"GCOV"
],
"dataset": [
"NISAR"
],
"productionConfiguration": [
"PR"
],
"dataMaturity" : "PROVISIONAL",
'session': session,
})
response = asf.search(opts=opts)
hdf5_files = response.find_urls(extension='.h5', directAccess=False)
hdf5_filesEDL Username aflewandowski
EDL Password ········
['https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_005_172_A_008_2005_DHDH_A_20251122T024618_20251122T024652_P05023_N_F_J_001/NISAR_L2_PR_GCOV_005_172_A_008_2005_DHDH_A_20251122T024618_20251122T024652_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_005_172_A_008_2005_DHDH_A_20251122T024618_20251122T024652_P05023_N_F_J_001/NISAR_L2_PR_GCOV_005_172_A_008_2005_DHDH_A_20251122T024618_20251122T024652_P05023_N_F_J_001_QA_STATS.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_006_165_D_082_2005_SHSH_A_20251203T154910_20251203T154945_P05023_N_F_J_001/NISAR_L2_PR_GCOV_006_165_D_082_2005_SHSH_A_20251203T154910_20251203T154945_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_006_165_D_082_2005_SHSH_A_20251203T154910_20251203T154945_P05023_N_F_J_001/NISAR_L2_PR_GCOV_006_165_D_082_2005_SHSH_A_20251203T154910_20251203T154945_P05023_N_F_J_001_QA_STATS.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_006_172_A_008_2005_DHDH_A_20251204T024618_20251204T024653_P05023_N_F_J_001/NISAR_L2_PR_GCOV_006_172_A_008_2005_DHDH_A_20251204T024618_20251204T024653_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_006_172_A_008_2005_DHDH_A_20251204T024618_20251204T024653_P05023_N_F_J_001/NISAR_L2_PR_GCOV_006_172_A_008_2005_DHDH_A_20251204T024618_20251204T024653_P05023_N_F_J_001_QA_STATS.h5']2b. Filter the results¶
Note that the results include the QA_STATS files as well as the GCOV products. If you only want the GCOV data, you can remove the QA_STATS files with a pattern (regex) filter when calling response.find_urls
# Don't run this code cell if you wish to download the QA_STATS data
# Include include a negative lookahead for "QA_STATS"
pattern = r'^(?!.*QA_STATS).*'
# To include the static files, remove the `pattern=pattern` argument below
hdf5_files = response.find_urls(extension='.h5', pattern=pattern, directAccess=False)
hdf5_files['https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_005_172_A_008_2005_DHDH_A_20251122T024618_20251122T024652_P05023_N_F_J_001/NISAR_L2_PR_GCOV_005_172_A_008_2005_DHDH_A_20251122T024618_20251122T024652_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_006_165_D_082_2005_SHSH_A_20251203T154910_20251203T154945_P05023_N_F_J_001/NISAR_L2_PR_GCOV_006_165_D_082_2005_SHSH_A_20251203T154910_20251203T154945_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GCOV_PROVISIONAL_V1/NISAR_L2_PR_GCOV_006_172_A_008_2005_DHDH_A_20251204T024618_20251204T024653_P05023_N_F_J_001/NISAR_L2_PR_GCOV_006_172_A_008_2005_DHDH_A_20251204T024618_20251204T024653_P05023_N_F_J_001.h5']2c. Download the data to a specified directory¶
from pathlib import Path
data_dir = Path.home() / "GCOV_data"
data_dir.mkdir(exist_ok=True)
print(f'data_dir: {data_dir}')
asf.download_urls(hdf5_files, data_dir, session=session, processes=4)data_dir: /home/jovyan/GCOV_data
3. Summary¶
You now have the tools and knowledge that you need to search and download data using the asf_search Python package.