CoastWatch Utilities: Exercise 3 - Creating a custom projection and compositing data
Goal: Use CWMaster to create a custom projection and use the CW Utility command cwregister2 to map data to the custom projection
In Exercise 2b, S-NPP Ocean Color data was quickly mapped to an orthographic projection. The command to perform the quick mapping is cwregister2 <in NetCDF/HDF> <out HDF> or in the specific case:
cwregister2 V2019290205647_NPP_NRTNIR_L2.nc out.hdf
The L2 data are considered unmapped/Swath and in the case of VIIRS is a single granule. How can we combine granules and composite them in the same mapped space?
CWMaster will be used to create a projection ‘masterfile’ that will be used with cwregister2 to map data to the same map space. In this example, we will use a projection used by California State government.
CWMaster is an application similar to CDAT. It can either duplicate projection information by loading a mapped dataset or by entering specific projection parameters. At a command prompt, type ‘cwmaster’.
In the Projection parameter box, enter the following data:
Units: Meters
1st Standard Parallel: 34 N
2nd Standard Parallel: 40.5 N
Longitude of Center of Projection (Central Meridian): 120 W
Latitude of Origin of Projection: 0 N
False Easting: 0
False Northing: -4000000
X shift: 0 Y shift: 0
Spheroid / Datum: GRS80 / NAD83 or Clarke 1866 / NAD27
Use File=>Save As, Ctrl-s, or the Save tool to save a filenamed ‘Albers_master.hdf’.
The output from CW Master is an HDF file containing the affine of the projection.
‘cwinfo’ is a command line tool to show the contents of a file. Using it on one of the ocean color Level-2 files, we see what’s inside:
C:\SampleData2022\SatelliteData >cwinfo V2022266205808_NPP_NRTNIR_L2.nc
Contents of V2022266205808_NPP_NRTNIR_L2.nc
Global information:
Data source: watermask.dat,digital_elevation_map.hdf,ice_mask.hdf,no2_climatology.hdf,alpha510_climatology.hdf,taua865_climatology.hdf,GMTCO_npp_d20220923_t2058088_e2059329_b56516_c20220923212325634356_oebc_ops.h5,
Date: 2022/09/23 JD 266
Start time: 20:58:11 UTC
End time: 20:59:35 UTC
Projection type: swath
Transform ident: noaa.coastwatch.util.trans.SwathProjection
Origin: NOAA/NESDIS Center for Satellite Applications and Research (STAR)
Format: Java-NetCDF interface (NetCDF-4 ucar.nc2.dataset.conv.CF1Convention)
Reader ident: noaa.coastwatch.io.CommonDataModelNCReader
Variable information:
Variable Type Dimensions Units Scale Offset
geophysical_data/chlor_a float 768x3200 mg m^-3 - -
geophysical_data/kd_490 short 768x3200 m^-1 0.001 -0
geophysical_data/kd_par short 768x3200 m^-1 0.001 -0
geophysical_data/nLw_410 short 768x3200 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_443 short 768x3200 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_486 short 768x3200 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_551 short 768x3200 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_638_ag short 768x3200 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_671 short 768x3200 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/qa_score short 768x3200 - 0.0001 -0
geophysical_data/l2_flags int 768x3200 - - -
scan_line_attributes/time int 768 milliseconds since 2022-09-23 00:00:00 - -
navigation_data/latitude float 768x3200 degree_north - -
navigation_data/longitude float 768x3200 degree_east - -
Now, we can map two S-NPP VIIRS Ocean Color Level-2 granules to this projection:
cwregister2 -v -M Albers_master.hdf V2022266205808_NPP_NRTNIR_L2.nc V2022266205808_NPP_NRTNIR_L3_Albers.hdf
cwregister2 -v -M Albers_master.hdf V2022266205643_NPP_NRTNIR_L2.nc V2022266205643_NPP_NRTNIR_L3_Albers.hdf
Errors may be because the Albers_master.hdf file is in another directory.
The mapped images can then be composited:
cwcomposite –v V2022266205808_NPP_NRTNIR_L3_Albers.hdf V2022266205643_NPP_NRTNIR_L3_Albers.hdf SNPP_VIIRS_20191017_Albers_composite.hdf
Using ‘cwinfo’ on the output you see the projection information and the dimensions of the new file:
C:\SampleData2022\exercise_outputs>cwinfo SNPP_VIIRS_20191017_Albers_composite.hdf
Contents of SNPP_VIIRS_20191017_Albers_composite.hdf
Global information:
Data source: SVM01_npp_d20220923_t2058088_e2059329_b56516_c20220923212447724787_oebc_ops.h5,S19461993_COADS_GEOS1.MET_noon,,,S19891991_TOMS.OZONE,,,radcor_modisa_nocor.hdf,polcor_viirsn_22bands_oc.hdf,landmask_USGS_15arc.nc,watermask.dat,digital_elevation_map.hdf,ice_mask.hdf,no2_climatology.hdf,alpha510_climatology.hdf,taua865_climatology.hdf,GMTCO_npp_d20220923_t2058088_e2059329_b56516_c20220923212325634356_oebc_ops.h5,, SVM01_npp_d20220923_t2056433_e2058075_b56516_c20220923212424008682_oebc_ops.h5,S19461993_COADS_GEOS1.MET_noon,,,S19891991_TOMS.OZONE,,,radcor_modisa_nocor.hdf,polcor_viirsn_22bands_oc.hdf,landmask_USGS_15arc.nc,watermask.dat,digital_elevation_map.hdf,ice_mask.hdf,no2_climatology.hdf,alpha510_climatology.hdf,taua865_climatology.hdf,GMTCO_npp_d20220923_t2056433_e2058075_b56516_c20220923212308666857_oebc_ops.h5,
Date: 2022/09/23 JD 266
Start time: 20:56:46 UTC
End time: 20:59:35 UTC
Projection type: mapped
Transform ident: noaa.coastwatch.util.trans.AlbersConicalEqualAreaProjection
Map projection: Albers Conical Equal Area
Map affine: 0 -1000 1000 0 -511500 4398517.59
Spheroid: GRS 1980
Origin: NOAA/NESDIS Center for Satellite Applications and Research (STAR)
Format: CoastWatch HDF version 3.4
Reader ident: noaa.coastwatch.io.CWHDFReader
Variable information:
Variable Type Dimensions Units Scale Offset
geophysical_data/chlor_a float 1024x1024 mg m^-3 - -
geophysical_data/kd_490 short 1024x1024 m^-1 0.001 -0
geophysical_data/kd_par short 1024x1024 m^-1 0.001 -0
geophysical_data/l2_flags int 1024x1024 - - -
geophysical_data/nLw_410 short 1024x1024 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_443 short 1024x1024 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_486 short 1024x1024 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_551 short 1024x1024 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_638_ag short 1024x1024 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/nLw_671 short 1024x1024 mW cm^-2 um^-1 sr^-1 0.001 -0
geophysical_data/qa_score short 1024x1024 - 0.0001 -0
navigation_data/latitude float 1024x1024 degree_north - -
navigation_data/longitude float 1024x1024 degree_east - -
Resulting in the output image viewed in CDAT with scaling, palettes, and overlays applied: