About Wind Animation

Starting from Oracle Spatial Studio Release 24.2.0, you can create and visualize wind animations that depict the direction of flow between various locations.

Although commonly referred to as wind animation, this visualization applies for any movement-based visualization. For instance, it can be used to render wind speeds, depict tectonic plate movements, or other vector-based simulations. The following figure shows a sample wind animation in Spatial Studio:

Description of the illustration sample_wind_map_viz.png

These visualizations rely on wind velocities along the x (u) and y (v) axes as input. These velocities are encoded within an image, where the red (R) and green (G) channels represent the x and y velocities, respectively. The values are scaled and mapped to an integer range of 0–255, with the R channel holding the u velocities and the G channel holding the v velocities.

The base image thus serves as a grid of u and v velocities at each integral longitude and latitude point within the specified bounding box (bbox). With this setup, the visualization generates random particles on the map, which are then animated according to the wind velocities, creating dynamic flowing visuals.

The following shows a sample base image that can be used to create a wind animation:

Description of the illustration sample_base_image.png

The base image for the wind animation can be generated from a NOAA dataset or from any other supported data providers (see Generating a Base Wind Image From a NOAA Dataset for an example). You can then load this image as GeoRaster to Oracle Database and create a wind animation dataset for visualization.

Generating a Base Wind Image From a NOAA Dataset

This section provides the steps for generating a base wind image using a NOAA provider.

You can generate a base image for creating a wind animation dataset from the NOAA GFS Dataset website or programmatically through scripts.

  1. Open the URL NOAA GFS Dataset in your browser.

  2. Select a Subdirectory for any specified data and time and proceed to the atmos option to work with atmospheric data.

  3. Set the file type to gfs.t06z.pgrb2.1p00.f000.

  4. Select the layer type as 10m above the ground.

  5. Select the UGRD (U-component of wind, eastward velocity) variable, specify the bounding box (bbox) you wish to analyze, and then click Start Download.

  6. Repeat the previous step for VGRD (V-component of wind, northward velocity).

    Note that the velocity grids are downloaded as GRIB files.

  7. Parse to extract the grid values from these files using GRIB tools (for example, wgrib2).

  8. Create the base image by combining the grid values for UGRD and VGRD.

    Note the following for creating the base image:

    • The R (Red) channel represents UGRD (x-axis velocities).

    • The G (Green) channel represents VGRD (y-axis velocities).

    • The velocity values must be scaled to fit within the 0-255 range, where umin, umax, vmin, and vmax represent the minimum and maximum values for the u (x-axis) and v (y-axis) velocities.

      These minimum and maximum values are crucial for encoding and decoding the velocity values from the base image, as they will be scaled to fit the 0-255 range for visualization purposes.

      Note: It is important that you note the data range values as these will be required to create the wind animation dataset for the first time in Spatial Studio.

    Alternatively, you can generate the base wind image programmatically through code as shown in the following example scripts.

    The following scripts describe the steps for downloading, parsing grid values, and finally writing them into an image format for use in visualization.

    download.sh

     #!/bin/bash
    
     GFS_DATE="20240719"
     GFS_TIME="00"; # 00, 06, 12, 18
     RES="1p00" # 0p25, 0p50 or 1p00
     BBOX="leftlon=0&rightlon=360&toplat=90&bottomlat=-90"
     LEVEL="lev_10_m_above_ground=on"
     GFS_URL="https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_${RES}.pl?dir=%2Fgfs.${GFS_DATE}%2F${GFS_TIME}%2Fatmos&file=gfs.t06z.pgrb2.1p00.f000&${LEVEL}=on&subregion=${BBOX}"
     curl "${GFS_URL}&var_UGRD=on" -o utmp.grib
     curl "${GFS_URL}&var_VGRD=on" -o vtmp.grib
    
     grib_set -r -s packingType=grid_simple utmp.grib utmp_out.grib
     grib_set -r -s packingType=grid_simple vtmp.grib vtmp_out.grib
    
     printf "{"u":`grib_dump -j utmp_out.grib`,"v":`grib_dump -j vtmp_out.grib`}" > tmp.json
    
     rm utmp.grib vtmp.grib utmp_out.grib vtmp_out.grib
    
     DIR=`dirname $0`
     node ${DIR}/prepare.js ${1}/${GFS_DATE}${GFS_TIME}

    prepare.js

     const PNG = require('pngjs').PNG;
     const fs = require('fs');
    
     const data = JSON.parse(fs.readFileSync('tmp.json'));
     const name = process.argv[2];
     const umessage = data.u.messages[0];
     const vmessage = data.v.messages[0];
    
     const unpack = (message) =>
         message.reduce((acc, { key, value }) => ({ ...acc, [key]: value }), {});
     const u = unpack(umessage);
     const v = unpack(vmessage);
    
     const width = u.Ni;
     const height = u.Nj;
    
     console.log(`Width: ${width}, Height: ${height}`);
     console.log(`u: min=${u.minimum}, max=${u.maximum}`);
     console.log(`v: min=${v.minimum}, max=${v.maximum}`);
     console.log(`u values length: ${u.values.length}, v values length: ${v.values.length}`);
    
     const png = new PNG({
         colorType: 2,
         filterType: 4,
         width: width,
         height: height
     });
    
     for (let y = 0; y < height; y++) {
         for (let x = 0; x < width; x++) {
             const i = (y * width + x) * 4;
             const k = y * width + x;
    
             if (k < 0 || k >= u.values.length || k >= v.values.length) {
                 console.error(`Index out of bounds at (x: ${x}, y: ${y}) -> k: ${k}`);
                 continue;
             }
    
             const uValue = u.values[k];
             const vValue = v.values[k];
    
             if (isNaN(uValue) || isNaN(vValue)) {
                 console.error(`Invalid value at (x: ${x}, y: ${y}) -> u: ${uValue}, v: ${vValue}`);
                 continue;
             }
    
             png.data[i + 0] = Math.floor(255 * (uValue - u.minimum) / (u.maximum - u.minimum));
             png.data[i + 1] = Math.floor(255 * (vValue - v.minimum) / (v.maximum - v.minimum));
             png.data[i + 2] = 0;
             png.data[i + 3] = 255;
         }
     }
    
     png.pack().pipe(fs.createWriteStream(`/Users/user1/Downloads/build/${name}.png`));
    
     fs.writeFileSync(`/Users/user1/Downloads/build/${name}.json`, JSON.stringify({
         source: 'http://nomads.ncep.noaa.gov',
         date: formatDate(u.dataDate + '', u.dataTime),
         width: width,
         height: height,
         uMin: u.minimum,
         uMax: u.maximum,
         vMin: v.minimum,
         vMax: v.maximum
     }, null, 2) + '\n');
    
     function formatDate(dateStr, timeStr) {
         const year = dateStr.slice(0, 4);
         const month = dateStr.slice(4, 6);
         const day = dateStr.slice(6, 8);
         const hour = String(timeStr).padStart(4, '0');
         return `${year}-${month}-${day}T${hour.slice(0, 2)}:00:00Z`;
     }

Visualizing a Wind Animation Dataset

You can create a wind animation visualization in Spatial Studio.

The following instructions assume that you have a wind animation enabled GeoRaster dataset and the dataset is already added to the project in the Active Project page. See Creating a Wind Animation Dataset and Enabling Wind Animation For an Existing GeoRaster Dataset for more information.

  1. Click the Visualizations tab on the left pane in the Active Project page.

    This lists the various visualization options.

  2. Click and drag Map from the list to the visualization window on the right to create a map visualization.

    A default base map is displayed with no data visualization layers.

  3. Click the Data tab on the left pane in the Active Project page.

    This lists all the Datasets that are loaded for the project.

  4. Click and drag the desired wind animation dataset from the list to the map view on the right.

    The wind animation visualization gets displayed as shown:

    Description of the illustration wind_map_viz.png

    Legend using a color scheme is supported for wind animations. However, pitch and rotation actions are not supported. If the view is rotated or pitched, then the wind animation will be disabled, and a warning will be displayed. The wind animation will automatically be reenabled once the pitch/rotate is returned to the default (0).

  5. Optionally, click Menu Icon against the wind animation dataset layer in the Data tab of the Layers list and configure the following properties.

    • Number of Particles: Controls how many particles are randomly drawn in the current viewport. These particles will be animated based on the wind velocities.

    • Speed Factor: A multiplier between zero and one that adjusts the on-screen movement in relation to the actual wind speed.

    • Fade Opacity: Manages the length of particle trails and when they should fade out, affecting the smoothness of the animation.

    • Set palette: Sets the color scheme for different ranges of wind velocity.