Skip to content

Scripts to generate daily snow depth maps for the United States

Notifications You must be signed in to change notification settings

srnicholson/Daily-Snow-Depth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

Daily-Snow-Depth

This repo contains scripts to generate (rough!) visualizations of daily U.S. snow depth. I used these scripts to generate timelapse visualizations of the snow depth map throughout the contiguous US from 1950 through 2015. A slow version and fast version are available.

The following guide explains how to download the underlying dataset, format it, import it into QGIS, and ultimately combine the resulting map frames into a timelapse video. I completed this project on a Windows machine, so this guide is highly Windows-specific.

I. Download the raw data

  1. This step requires wget, available here for Windows
  2. The data we want to use is provided by the National Climate Data Center's Global Historical Climatological Network, and is available via FTP server here.
  3. To download some or all of the yearly GHCND files (CAUTION: over 13 GB total!): 1. Edit download_by_year.bat to specify the year range to download 2. Edit download_by_year.bat to specify the save directory
  4. Extract the csv files within these .gz files using a utility like 7-zip

II. Format the raw data

  1. This step requires a Unix shell. If you are on Windows, consider Cygwin:
  2. These .csv files contain all weather data for every station in the Global Historical Climate Network (GHCN). We only need the snow depth data from U.S. stations.
  3. From the terminal (on Windows, open Cygwin), navigate to the location of the csv files.
  4. Run format_raw_data.sh from the Cygwin terminal. This will create a new directory containing daily csv files for snow depth data at continental U.S. stations. The files are named in the following way: YYYYMMDD.csv

III. Create spatially-interpolated snow depth maps

  1. This step requires QGIS, and specifically, QGIS 2.10 Pisa.
    1. The script is not working with more recent QGIS versions (such as 2.14 Essen) due to a backwards compatibility issue in some of the processing algorithms.

    2. Links to the older QGIS 2.10 Windows installation binaries

      1. QGIS-OSGeo4W-2.10.1-1-Setup-x86.exe (32-bit version)
      2. QGIS-OSGeo4W-2.10.1-1-Setup-x86_64.exe (64-bit version)
  2. Open QGIS 2.10
  3. Uncheck the box next to "Render" in the QGIS window. This will speeds up the script because it prevents QGIS from displaying the intermediate canvases during processing.
  4. Click the Python logo to open the Python Console within QGIS.
  5. Click "Show Editor"
  6. Click "Open file" and load the QGIS_Snow_Depth_Renderer.py script.
  7. IMPORTANT : You will need to edit line 6 of QGIS_Snow_Depth_Renderer.py to specify the correct path to your local GitHub repository housing the Daily-Snow-Depth files.
  8. Please take note of the warnings and suggestions below BEFORE running QGIS_Snow_Depth_Renderer.py. * This is a very time-consuming and processor-intensive task; rendering takes approximately 30-45 seconds per map, depending on your hardware. * I recommend only running the script for a few years' worth of daily files (up to a decade) at a time, since the temporary files generated by QGIS take up a lot of space and are not removed until the QGIS session is terminated. If you know/find a way to delete temp files while the script is running, please share it! * You may need to go in and manually delete the temp files if QGIS fails to remove them. On Windows, the default temp directory is something like C:\Users\[your-name-here]\AppData\Local\Temp\processing * If you are using an SSD for your OS and installed programs and a larger HDD for bulk storage, consider changing the environment variable of the QGIS temp directory to a location on your HDD, as explained here: http://gis.stackexchange.com/a/156156 * The warning message about incompatible CRS layers can be ignored.
  9. Run QGIS_Snow_Depth_Renderer.py, which will save the individual map files to the [Your GitHub path]/Daily-Snow-Depth/QGIS_Python/Rendered_Frames/ directory in YYYYMMDD.png format.

IV. Create timelapse video from daily map images

  1. **This step requires the following:

    1. Avisynth, available here
    2. MeGUI, available here
    3. An up-to-date version of ffmpeg, available here (or here if you wish to use a build that has already been compiled)
  2. Crop maps to remove headers (will be added in separately in later steps.)

    Run crop_maps.sh in the command line.

  3. Generate timelapse for all map images (after cd'ing to wherever the individual map files are) using:

    ffmpeg -framerate 2 -i %05d.png -c:v libx264 -preset veryslow -r 2 -pix_fmt yuv420p {maps_out.mkv}

  4. Generate date headers for all map images. These are handled separately by isolating them off the previously rendered map frames so that the header dates appear plainly and sequentially instead of blending one into another (which is hard to read) in the final timelapse.

    Run crop_headers.sh in the command line.

  5. Generate timelapse for all header images (after cd'ing to wherever the individual header files are):

    ffmpeg -framerate 2 -i %05d.png -c:v libx264 -preset veryslow -r 30 {headers_out.mkv}

  6. Stack the non-blended header and blended map video files:

    ffmpeg -i {headers_out.mkv} -i {maps_out.mkv} -filter_complex vstack {stacked.mkv}

  7. Upload to desired video hosting platform (e.g., Youtube or Vimeo).

About

Scripts to generate daily snow depth maps for the United States

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published