[][src]Crate tiler

A netCDF to tile converter. This crate provides basic methods to export a netCDF gridded dataset into PNG tiles, suited for interactive web maps.

Usage

In order to export a netCDF file into PNGs you need to create 2 objects:

Here is a simple example:

// Create a dataset from a netCDF file
let dataset = tiler::Dataset::new(
    "latitude",         // Name of the latitude dimension
    "longitude",        // Name of the longitude dimension
    "wind_magnitude",   // Name of the latitude dimension
    "./examples_data/wind_magnitude_reduced.nc" // Path to a dataset
).unwrap();
 
// Create a renderer
let renderer = tiler::Renderer::from_dataset(
    dataset,        // input dataset
    tiler::Scale::Linear { // Use a linear range of color
        min: 0., // minimum value of the colorbar
        max: 20.  // maximum value of the colorbar 
    },
    tiler::ColorMap::RdYlBu_r   // The ColorMap you want to use, (Red Yellow Blue)
).unwrap();
 
// create a Tile Struct
let tile = tiler::Tile {x: 0, y: 0, z: 0 };
 
// render it into an image (TileImg)
if let Ok(img) = renderer.render_tile(&tile) {
    // save it as a png file
    img.save("./tile_0_0_0.png");
}

Structs

CustomColormap

This struct represents a user defined color map, It should directly map values to colors

Dataset

This Struct provides access to the data within a netCDF file.

ImgTile

This struct represents an image tile, it holds all the pixel values needed to build an image file (PNG) from it.

Renderer

Provides convenient functions to render a Dataset instance into ImgTiles

Tile

This struct holds basic informations about a Tile.

TileData

Holds data and provides methods to regrid data into a 256 x 256 grid.

Enums

ColorMap

Defines values to color association.

Scale

Enum that describes how the transcription from a value to a color is done.

Functions

normalize

Describe how a value will be translated to a color domain