How to extract the daily SWE and snow depth values and convert them to GeoTIFFs

If you need to use data from Daily 4km Gridded SWE and Snow Depth from Assimilated In-Situ and Modeled Data over the Conterminous US, Version 1 in a GIS (e.g. ArcMap, QGIS), we suggest converting the NetCDFs to GeoTIFFs first. We recommend using the Geospatial Data Abstraction Library (GDAL) to do this, and instructions for downloading and installing GDAL can be found here:
https://gdal.org/download.html

Below are instructions for using GDAL directly in the command line or in a python script.

Command line

  1. Once GDAL is installed, open a command prompt/terminal and navigate to where the NetCDF files are stored.
     
  2. The SWE and DEPTH variables in the NetCDFs contain the 365 or 366 daily arrays. You can use the gdal_translate command to convert the variable(s) and day(s) you are interested in. For example, to convert the first day of data for the SWE variable from the 2020 NetCDF:

    gdal_translate NETCDF:4km_SWE_Depth_WY2020_v01.nc:SWE -b 1 -a_srs EPSG:4326 out.tif

    To convert day 172 of data for the DEPTH variable from the 2020 NetCDF:

    gdal_translate NETCDF:4km_SWE_Depth_WY2020_v01.nc:DEPTH -b 172 -a_srs EPSG:4326 out.tif

Python

Below is some example python code for extracting the DEPTH variable for day 246 from the 2020 NetCDF:

from osgeo import gdal

ds = gdal.Open('C:/set/file/path/4km_SWE_Depth_WY2020_v01.nc')

# Get list of subdatasets in the netCDF file
ds.GetSubDatasets()

ds_sub = ('NETCDF:"C:/set/file/path/4km_SWE_depth_WY2020_v01.nc":DEPTH')
trans = gdal.Translate('C:/set/file/path/out.tif', ds_sub, bandList = [246], outputSRS = 'EPSG:4326')