This notebook demonstrates how to load GCOV data with ISCE3’s NISAR Product Reader.
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 a GCOV product¶
2a. Search for GCOV data with asf_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)
pattern = r'^(?!.*QA_STATS).*'
hdf5_files = response.find_urls(extension='.h5', pattern=pattern, 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_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']2b. Download a GCOV product¶
from pathlib import Path
data_dir = Path.home() / "load_subset_reproject_isce3_GCOV_data"
data_dir.mkdir(exist_ok=True)
print(f'data_dir: {data_dir}')
asf.download_url(hdf5_files[0], data_dir, session=session)data_dir: /home/jovyan/load_subset_reproject_isce3_GCOV_data
3. Load an HDF5 dataset as a GenericProduct.GCOV object¶
from nisar.products.readers import open_product
from pathlib import Path
data_dir = Path.home() / "GCOV_data"
data_dir.mkdir(exist_ok=True)
gcov_path = list(data_dir.glob("*.h5"))[0]
gcov = open_product(gcov_path)
gcov<nisar.products.readers.GenericProduct.GCOV.GCOV at 0x7ff8392becf0>4. View the GCOV metadata¶
The GCOV object contains member variables, methods, and additional ISCE3 objects that all hold product metadata.
4a. View the available GCOV member variables.¶
gcov_member_variables = {
"CFPath": gcov.CFPath,
"CalibrationInformationPath": gcov.CalibrationInformationPath,
"GridPath": gcov.GridPath,
"IdentificationPath": gcov.IdentificationPath,
"MetadataPath": gcov.MetadataPath,
"ProcessingInformationPath": gcov.ProcessingInformationPath,
"ProductPath": gcov.ProductPath,
"RootPath": gcov.RootPath,
"SwathPath": gcov.SwathPath,
"covarianceTerms": gcov.covarianceTerms,
"error_channel": gcov.error_channel,
"filename": gcov.filename,
"frequencies": gcov.frequencies,
"identification": gcov.identification,
"polarizations": gcov.polarizations,
"productType": gcov.productType,
"productValidationType": gcov.productValidationType,
"sarBand": gcov.sarBand,
"sourceDataPath": gcov.sourceDataPath,
"sourceDataProcessingInfoPath": gcov.sourceDataProcessingInfoPath,
"sourceDataSwathsPath": gcov.sourceDataSwathsPath
}
max_len = max(len(v) for v in sorted(gcov_member_variables.keys()))
for k, v in gcov_member_variables.items():
print(f"{k:{max_len}} {v}")CFPath /
CalibrationInformationPath /science/LSAR/GCOV/metadata/calibrationInformation
GridPath /science/LSAR/GCOV/grids
IdentificationPath /science/LSAR/identification
MetadataPath /science/LSAR/GCOV/metadata
ProcessingInformationPath /science/LSAR/GCOV/metadata/processingInformation
ProductPath /science/LSAR/GCOV
RootPath /science/LSAR
SwathPath /science/LSAR/GCOV/swaths
covarianceTerms {'A': ['HHHH'], 'B': ['HHHH']}
error_channel <journal.ext.journal.Error object at 0x7ff83929d630>
filename /home/jovyan/GCOV_data/NISAR_L2_PR_GCOV_006_165_D_082_2005_SHSH_A_20251203T154910_20251203T154945_P05023_N_F_J_001.h5
frequencies ['A', 'B']
identification <nisar.products.readers.Base.Identification.Identification object at 0x7ff8392beba0>
polarizations {'A': ['HH'], 'B': ['HH']}
productType GCOV
productValidationType GCOV
sarBand L
sourceDataPath /science/LSAR/GCOV/metadata/sourceData
sourceDataProcessingInfoPath /science/LSAR/GCOV/metadata/sourceData/processingInformation
sourceDataSwathsPath /science/LSAR/GCOV/metadata/sourceData/swaths
4b. View the GCOV get metadata methods¶
gcov_metadata_functions = {
'getCenterFrequency("B")': gcov.getCenterFrequency("B"),
'getProjectionEpsg()': gcov.getProjectionEpsg(),
'getGeoGridCoordinateSpacing()': gcov.getGeoGridCoordinateSpacing(),
'getProductLevel()': gcov.getProductLevel(),
'getWavelength("B")': gcov.getWavelength("B"),
}
max_len = max(len(v) for v in sorted(gcov_metadata_functions.keys()))
for k, v in gcov_metadata_functions.items():
print(f"{k:{max_len}} {v}") getCenterFrequency("B") 1293500000.0
getProjectionEpsg() 32637
getGeoGridCoordinateSpacing() (np.float64(20.0), np.float64(-20.0))
getProductLevel() L2
getWavelength("B") 0.23176842520293778
4c. View the metadata contained in the GCOV.Identification object¶
gcov_identification_member_variables = {
"absoluteOrbitNumber": gcov.identification.absoluteOrbitNumber,
"boundingPolygon": gcov.identification.boundingPolygon,
"diagnosticModeFlag": gcov.identification.diagnosticModeFlag,
"diagnosticModeName": gcov.identification.diagnosticModeName,
"isJointObservation": gcov.identification.isJointObservation,
"isUrgentObservation": gcov.identification.isUrgentObservation,
"listOfFrequencies": gcov.identification.listOfFrequencies,
"lookDirection": gcov.identification.lookDirection,
"missionId": gcov.identification.missionId,
"orbitPassDirection": gcov.identification.orbitPassDirection,
"plannedDatatake": gcov.identification.plannedDatatake,
"plannedObservation": gcov.identification.plannedObservation,
"productType": gcov.identification.productType,
"zdEndTime": gcov.identification.zdEndTime,
"zdStartTime": gcov.identification.zdStartTime
}
max_len = max(len(v) for v in sorted(gcov_identification_member_variables.keys()))
for k, v in gcov_identification_member_variables.items():
print(f"{k:{max_len}} {v}") absoluteOrbitNumber 1821
boundingPolygon POLYGON ((39.3607818607813 14.248319051321 2366.32299804807,39.3022440954932 14.0353996252947 1920.51611328076,39.2528727594568 13.8203543335465 2146.03141875786,39.2031781674395 13.605400060416 2339.21289062466,39.1510502548509 13.3910285664428 2342.67673431043,39.0903509117753 13.1786665059479 1699.29797253048,39.0418556430526 12.9634771118623 1955.34949191018,38.9895649839527 12.7491856297675 1920.54272460449,38.9405065461852 12.5341567304984 2118.45117163637,38.8899058799918 12.3195011819149 2193.1989746094,38.8355231204151 12.1057371844582 1977.051881154,39.105042126914 12.0430481535428 2839.22933084966,39.351219285236 11.9855337470481 2743.70166015741,39.585353974324 11.9306086896252 2364.19360351464,39.8070861634776 11.8783919458353 1500.87622070886,40.0259085004577 11.8266703393676 929.145080566761,40.2435419724795 11.7750433320617 792.59588622948,40.4580225311253 11.7239827171872 868.341917433096,40.6659195655971 11.6743173346755 732.590942862322,40.8685237623613 11.6257539870167 453.404297236463,41.0693451794416 11.5774609036758 391.973358176654,41.1220851484284 11.7910753378977 357.671629673897,41.1753740465271 12.0045762211667 372.472320068136,41.2310359694756 12.2175228353977 657.350585938025,41.2837311645079 12.4312042777191 564.4177252941,41.3356594145756 12.6450914890745 360.764007496071,41.386878329944 12.8591714146587 53.6302496318487,41.4403527020296 13.0727238657351 1.17880354479943,41.4989848875353 13.2850417667127 553.113159422424,41.5543348077717 13.498176021642 689.654541016483,41.6092566977663 13.7114333788479 755.517499544989,41.403075083573 13.7616331451112 348.147064615432,41.2012018335011 13.8105958394132 877.473144558329,40.9861975006515 13.8625384491152 408.198211669157,40.7660249698119 13.9155099042516 -68.7799980265842,40.5444380784572 13.968596435283 -121.493690606265,40.3173819404775 14.0227583507183 -115.565315447162,40.0940307787161 14.0758035202348 831.546661218582,39.8627229190827 14.1304945711891 1682.65581467991,39.6251371186545 14.1864109416176 2675.80200195427,39.3607818607813 14.248319051321 2366.32299804807))
diagnosticModeFlag 0
diagnosticModeName Science/DBF
isJointObservation False
isUrgentObservation False
listOfFrequencies ['A', 'B']
lookDirection Left
missionId NISAR
orbitPassDirection Descending
plannedDatatake ['dtid_2025337153700']
plannedObservation ['oid_2025337154812']
productType GCOV
zdEndTime 2025-12-03T15:49:45.999342105
zdStartTime 2025-12-03T15:49:10.000000000
4d. Get the GCOV Orbit object¶
orbit = gcov.getOrbit()
orbit<isce3.ext.isce3.core.Orbit at 0x7ff83933a970>View the Orbit object member variables¶
orbit_member_variables = {
"end_datetime": orbit.end_datetime,
"end_time": orbit.end_time,
"mid_datetime": orbit.mid_datetime,
"mid_time": orbit.mid_time,
"position": orbit.position,
"reference_epoch": orbit.reference_epoch,
"size": orbit.size,
"spacing": orbit.spacing,
"start_datetime": orbit.start_datetime,
"start_time": orbit.start_time,
"position": orbit.position,
"velocity": orbit.velocity,
}
max_len = max(len(v) for v in sorted(orbit_member_variables.keys()))
for k, v in orbit_member_variables.items():
print(f"{k:{max_len}} {v}") end_datetime 2025-12-03T15:55:52.000000000
end_time 57352.0
mid_datetime 2025-12-03T15:50:37.000000000
mid_time 57037.0
position [[ 4885216.26875639 3911006.72558519 3410248.61705241]
[ 4923211.17916032 3919601.00076722 3345342.60234317]
[ 4960678.85544267 3927710.78278835 3280067.31606917]
[ 4997614.47941606 3935335.95070901 3214429.95963688]
[ 5034013.29133197 3942476.44425238 3148437.77469761]
[ 5069870.59072318 3949132.26330761 3082098.04253884]
[ 5105181.73683138 3955303.46797949 3015418.08343474]
[ 5139942.14940027 3960990.17849148 2948405.25555823]
[ 5174147.30905064 3966192.57530004 2881066.95426169]
[ 5207792.75813731 3970910.89872574 2813410.61116741]
[ 5240874.10114132 3975145.44887254 2745443.69366994]
[ 5273387.00536366 3978896.58580033 2677173.70346911]
[ 5305327.20139287 3982164.72933789 2608608.17601528]
[ 5336690.48384145 3984950.3586599 2539754.67978153]
[ 5367472.71171614 3987254.01242358 2470620.81539598]
[ 5397669.8092896 3989076.28816292 2401214.21485966]
[ 5427277.76619733 3990417.84299705 2331542.54025423]
[ 5456292.63842294 3991279.39251323 2261613.48349054]
[ 5484710.54855181 3991661.71127877 2191434.76491427]
[ 5512527.68641916 3991565.63235348 2121014.13268418]
[ 5539740.30961186 3990992.0470891 2050359.36197565]
[ 5566344.74392335 3989941.9051226 1979478.25388576]
[ 5592337.38387268 3988416.21416731 1908378.63449905]
[ 5617714.69324436 3986416.03950743 1837068.35451534]
[ 5642473.20544841 3983942.50439458 1765555.28737956]
[ 5666609.52424004 3980996.78906828 1693847.32930264]
[ 5690120.32383336 3977580.13118875 1621952.39799918]
[ 5713002.34983381 3973693.82482033 1549878.43207626]
[ 5735252.41939242 3969339.22073255 1477633.38980998]
[ 5756867.42144367 3964517.72648978 1405225.24807313]
[ 5777844.31760205 3959230.80535554 1332662.00189537]
[ 5798180.14224639 3953479.97663481 1259951.66319035]
[ 5817872.00309555 3947266.81507795 1187102.2601054 ]
[ 5836917.08159837 3940592.95064247 1114121.83603583]
[ 5855312.63339036 3933460.06812066 1041018.4486601 ]
[ 5873055.98822265 3925869.90757482 967800.16870862]
[ 5890144.55090978 3917824.2630528 894475.07954935]
[ 5906575.80138027 3909324.98282806 821051.27584702]
[ 5922347.29513489 3900373.96881252 747536.86318035]
[ 5937456.66360184 3890973.17630855 673939.95661767]
[ 5951901.61450324 3881124.61357789 600268.68005109]
[ 5965679.93208602 3870830.34162936 526531.16547518]
[ 5978789.477179 3860092.47438822 452735.55104748]
[ 5991228.18805517 3848913.17734308 378889.98148862]
[ 6002994.08039121 3837294.66779453 305002.60649629]
[ 6014085.24764763 3825239.21434892 231081.5798854 ]
[ 6024499.8613605 3812749.1365277 157135.05872582]
[ 6034236.1712759 3799826.80461474 83171.20233644]
[ 6043292.50590668 3786474.63880735 9198.17149783]
[ 6051667.27256494 3772695.10917258 -64775.87255508]
[ 6059358.95731445 3758490.73569597 -138742.76944878]
[ 6066366.12586151 3743864.08684096 -212694.35994904]
[ 6072687.42366865 3728817.77934302 -286622.48667496]
[ 6078321.57526224 3713354.47910882 -360518.99656162]
[ 6083267.38545524 3697476.89924679 -434375.74031447]
[ 6087523.73921238 3681187.80013825 -508184.57365208]
[ 6091089.60191352 3664489.98888973 -581937.35808617]
[ 6093964.0191357 3647386.31938496 -655625.96261235]
[ 6096146.11714712 3629879.69136663 -729242.26401212]
[ 6097635.10294477 3611973.05019863 -802778.1476395 ]
[ 6098430.26453096 3593669.38609648 -876225.50871898]
[ 6098530.97074199 3574971.73419517 -949576.25308064]
[ 6097936.67173973 3555883.17348168 -1022822.29799347]
[ 6096646.89876066 3536406.82683488 -1095955.57337888]]
reference_epoch 2025-12-03T00:00:00.000000000
size 64
spacing 10.0
start_datetime 2025-12-03T15:45:22.000000000
start_time 56722.0
velocity [[ 3825.68517815 883.64532817 -6471.88949888]
[ 3773.20468207 835.20414455 -6509.17529823]
[ 3720.23946437 786.74784973 -6545.7430148 ]
[ 3666.79534468 738.28248789 -6581.58856451]
[ 3612.87820661 689.81409684 -6616.7079441 ]
[ 3558.49399702 641.34870712 -6651.09723189]
[ 3503.64872505 592.89234119 -6684.75258835]
[ 3448.34846122 544.45101262 -6717.67025666]
[ 3392.59933658 496.03072521 -6749.84656307]
[ 3336.40754182 447.63747228 -6781.27791735]
[ 3279.77932656 399.27723606 -6811.96081305]
[ 3222.72099861 350.95598676 -6841.89182796]
[ 3165.23892331 302.67968205 -6871.06762447]
[ 3107.33952284 254.45426621 -6899.48495001]
[ 3049.0292755 206.28566953 -6927.14063756]
[ 2990.31471501 158.17980725 -6954.03160608]
[ 2931.20242971 110.14257904 -6980.15486092]
[ 2871.6990618 62.17986793 -7005.50749431]
[ 2811.81130649 14.29753961 -7030.08668565]
[ 2751.54591123 -33.49855839 -7053.88970194]
[ 2690.90967489 -81.20259746 -7076.91389808]
[ 2629.90944693 -128.80876874 -7099.15671723]
[ 2568.55212658 -176.31128386 -7120.61569117]
[ 2506.84466205 -223.70437561 -7141.28844059]
[ 2444.79404963 -270.98229885 -7161.1726755 ]
[ 2382.40733289 -318.1393312 -7180.2661955 ]
[ 2319.69160176 -365.16977369 -7198.56689012]
[ 2256.65399167 -412.0679517 -7216.07273911]
[ 2193.30168266 -458.82821561 -7232.78181277]
[ 2129.64189848 -505.44494151 -7248.69227219]
[ 2065.68190563 -551.91253208 -7263.80236958]
[ 2001.42901245 -598.22541731 -7278.1104485 ]
[ 1936.89056808 -644.37805528 -7291.61494413]
[ 1872.07396142 -690.36493293 -7304.31438347]
[ 1806.98662007 -736.1805669 -7316.20738547]
[ 1741.63600923 -781.81950412 -7327.29266114]
[ 1676.02963065 -827.27632266 -7337.56901349]
[ 1610.17502158 -872.54563229 -7347.03533758]
[ 1544.07975388 -917.62207509 -7355.69062037]
[ 1477.75143304 -962.50032609 -7363.53394074]
[ 1411.19769744 -1007.17509385 -7370.56446939]
[ 1344.42621758 -1051.64112097 -7376.78146891]
[ 1277.44469526 -1095.89318481 -7382.18429386]
[ 1210.26086284 -1139.92609811 -7386.77239089]
[ 1142.8824824 -1183.73470959 -7390.54529893]
[ 1075.31734482 -1227.3139047 -7393.50264937]
[ 1007.57326884 -1270.65860628 -7395.64416627]
[ 939.65810009 -1313.76377518 -7396.96966648]
[ 871.57970989 -1356.62441104 -7397.47905982]
[ 803.34599426 -1399.23555289 -7397.17234912]
[ 734.96487275 -1441.59227979 -7396.04963029]
[ 666.44428731 -1483.6897116 -7394.11109226]
[ 597.79220109 -1525.5230096 -7391.35701692]
[ 529.01659748 -1567.0873772 -7387.78777899]
[ 460.12547881 -1608.37806062 -7383.40384578]
[ 391.12686539 -1649.39034957 -7378.20577699]
[ 322.02879442 -1690.11957786 -7372.19422436]
[ 252.83931895 -1730.56112393 -7365.36993143]
[ 183.56650693 -1770.71041137 -7357.73373316]
[ 114.21844031 -1810.56290927 -7349.28655576]
[ 44.80321403 -1850.11413267 -7340.02941644]
[ -24.6710648 -1889.35964286 -7329.96342339]
[ -94.19627798 -1928.2950478 -7319.08977563]
[ -163.76429714 -1966.91600247 -7307.409763 ]]
View the Orbit object methods¶
orbit_methods = {
"get_type": orbit.get_type(),
"get_interp_method": orbit.get_interp_method(),
}
max_len = max(len(v) for v in sorted(orbit_methods.keys()))
for k, v in orbit_methods.items():
print(f"{k:{max_len}} {v}")get_type MOE
get_interp_method OrbitInterpMethod.HERMITE
4e. Get the GCOV’s RadarGridParameters object¶
radar_grid_param = gcov.getSourceRadarGridParameters("B")
radar_grid_param<isce3.ext.isce3.product.RadarGridParameters at 0x7ff83a8b0270>View the RadarGridParameters object’s member variables¶
radar_grid_params = {
"az_time_interval": radar_grid_param.az_time_interval,
"end_range": radar_grid_param.end_range,
"length": radar_grid_param.length,
"lookside": radar_grid_param.lookside,
"mid_range": radar_grid_param.mid_range,
"prf": radar_grid_param.prf,
"range_pixel_spacing": radar_grid_param.range_pixel_spacing,
"ref_epoch": radar_grid_param.ref_epoch,
"sensing_datetime()": radar_grid_param.sensing_datetime(),
"sensing_mid": radar_grid_param.sensing_mid,
"sensing_start": radar_grid_param.sensing_start,
"sensing_stop": radar_grid_param.sensing_stop,
"shape": radar_grid_param.shape,
"size": radar_grid_param.size,
"starting_range": radar_grid_param.starting_range,
"wavelength": radar_grid_param.wavelength,
"width": radar_grid_param.width,
}
max_len = max(len(v) for v in sorted(radar_grid_params.keys()))
for k, v in radar_grid_params.items():
print(f"{k:{max_len}} {v}") az_time_interval 0.0006578947368421052
end_range 1046725.367107
length 54720
lookside LookSide.Left
mid_range 964444.8287384167
prf 1520.0
range_pixel_spacing 24.982704833333333
ref_epoch 2025-12-03T00:00:00.000000000
sensing_datetime() 2025-12-03T15:49:10.000000000
sensing_mid 56967.99967105263
sensing_start 56950.0
sensing_stop 56985.999342105264
shape (54720, 6588)
size 360495360
starting_range 882164.2903698334
wavelength 0.23176842520293778
width 6588
4f. Get the GCOV’s GeoGridParameters object¶
geo_grid_param = gcov.getGeoGridParameters("B", "HHHH")
geo_grid_param<isce3.ext.isce3.product.GeoGridParameters at 0x7ff83929ac70>View the GeoGridParameters object’s member variables¶
geo_grid_params = {
"end_y": geo_grid_param.end_y,
"end_x": geo_grid_param.end_x,
"epsg":geo_grid_param.epsg,
"length": geo_grid_param.length,
"spacing_x": geo_grid_param.spacing_x,
"spacing_y": geo_grid_param.spacing_y,
"start_x": geo_grid_param.start_x,
"start_y": geo_grid_param.start_y,
"width": geo_grid_param.width
}
max_len = max(len(v) for v in sorted(geo_grid_params.keys()))
for k, v in geo_grid_params.items():
print(f"{k:{max_len}} {v}") end_y 1254240.0
end_x 804240.0
epsg 32637
length 4140
spacing_x 80.0
spacing_y -80.0
start_x 465840.0
start_y 1585440.0
width 4230
5. Load a backscatter or covariance image dataset¶
hh_backscatter_power = gcov.getImageDataset(frequency='B', polarization='HHHH')
hh_backscatter_power<HDF5 dataset "HHHH": shape (4140, 4230), type "<f4">6. Subset the data by index¶
hh_subset = hh_backscatter_power[2000:2500, 2000:2500]
print(f"hh_subset.shape: {hh_subset.shape}")
hh_subsethh_subset.shape: (500, 500)
array([[0.0602355 , 0.05916023, 0.05186033, ..., 0.12300777, 0.12761307,
0.16632271],
[0.06679344, 0.07860661, 0.0487752 , ..., 0.18728447, 0.19374847,
0.17194939],
[0.03771687, 0.04844141, 0.07712841, ..., 0.21936798, 0.1552391 ,
0.20528793],
...,
[0.10801315, 0.10937691, 0.07564354, ..., 0.12128353, 0.13926125,
0.19968987],
[0.09237671, 0.07653236, 0.07016945, ..., 0.2156372 , 0.21333504,
0.19182587],
[0.08720207, 0.0366807 , 0.07624817, ..., 0.1162014 , 0.18413925,
0.2521057 ]], shape=(500, 500), dtype=float32)7. Reproject the data¶
There are multiple ways to reproject the data. GCOV objects do not have a reprogection method, so you will need to use other tools. This example uses xarray and rioxarray.
import xarray as xr
import rioxarray
# Load the image layer in an xarray.DataArray
da = xr.DataArray(
hh_backscatter_power[...],
dims=("y", "x"),
name="HHHH",
)
# Add spatial coords to the DataArray
x_coords, y_coords = gcov.getGeoGridCoordinateDatasets("B")
da = da.assign_coords(y=("y", y_coords), x=("x", x_coords))
# Add the current CRS to the DataArray
epsg = gcov.getProjectionEpsg()
da = da.rio.write_crs(f"EPSG:{epsg}", inplace=True)
# Set the y and x coords as spatial dimensions
da = da.rio.set_spatial_dims(x_dim="x", y_dim="y", inplace=True)
# reproject the data
da_reproj = da.rio.reproject("EPSG:4326", inplace=True)
hh_reproj_subset = da_reproj[2000:2500, 2000:2500]
hh_reproj_subsethh_reproj_subset.spatial_ref.attrs{'crs_wkt': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
'semi_major_axis': 6378137.0,
'semi_minor_axis': 6356752.314245179,
'inverse_flattening': 298.257223563,
'reference_ellipsoid_name': 'WGS 84',
'longitude_of_prime_meridian': 0.0,
'prime_meridian_name': 'Greenwich',
'geographic_crs_name': 'WGS 84',
'horizontal_datum_name': 'World Geodetic System 1984',
'grid_mapping_name': 'latitude_longitude',
'spatial_ref': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
'GeoTransform': '38.68320570680618 0.0007302550640378555 0.0 14.341001854381084 0.0 -0.0007302550640378555'}7. Calculate statistics and transformations on the data¶
As a loaded HDF5 dataset, you can call many numpy functions directly on the data.¶
import numpy as np
print(f"min: {np.nanmin(hh_backscatter_power)}")
print(f"max: {np.nanmax(hh_backscatter_power)}")
print(f"mean: {np.nanmean(hh_backscatter_power)}")min: 8.144560601029e-17
max: 142.82421875
mean: 0.15281380712985992
Note that some numpy functions and attributes are not available with the loaded HDF5 dataset¶
For example, the code cell below will raise an AttributeError when trying to view the T (transpose attribute)
hh_backscatter_power.T---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[19], line 1
----> 1 hh_backscatter_power.T
AttributeError: 'Dataset' object has no attribute 'T'To view the T attribute, you must first read the data into memory as a numpy.ndarray¶
You can trigger the data to be read into memory by indexing the entire dataset with [...]:
hh_backscatter_power.T -> hh_backscatter_power[...].T
print(f"hh_backscatter_power.shape: {hh_backscatter_power.shape}")
print(f"hh_backscatter_power[...].T.shape: {hh_backscatter_power[...].T.shape}\n")
hh_backscatter_power[...].T8. Plot the data¶
Convert the data from linear scale (power) to logarithmic scale (dB) for visualization¶
hh_backscatter_dB = 10 * np.log10(hh_backscatter_power)Plot the image data in dB¶
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 10))
plt.imshow(hh_backscatter_dB, cmap="gray", vmin=-30.0, vmax=10.0)
plt.colorbar(label="HH Backscatter (dB)")
plt.title("HH Backscatter (dB)")
plt.show()
4. Summary¶
You have now run an example that loads NISAR GCOV data with isce3, accesses its metadata, creates a subset, reprojects the data, and plots an image layer.