Skip to content

DataSources and Renderers

Erik Vullings edited this page May 27, 2015 · 3 revisions

In csWeb, we support several data sources, such as geojson, topojson, grid files etc. After loading the data file, the data is typically converted to a generic render format, such as geojson, that is used by leaflet, cesium or both. Some of these data sources require additional parameters, such as described here.

GridDataSource

The grid data source can be used to load a number of different text based raster files, including ESRI ASCII grid files. Every grid cell that is within the constraints is converted to a geojson rectangle. Although it is quite flexible, please consider the fact that even a small grid file with 800x600 cells will generate 480.000 geojson features, way too much for leaflet to handle. You can use a min/max threshold to reduce the number of cells that will be converted to a geojson feature, but take care. We are considering supporting also an alternative render type of image, which is more suitable for this task, but will require special treatment when dealing with styles and filters.

A typical layer (in this case, displaying the Aurora data source), may look as follows:

        {
            "id": "Aurora",
            "refreshTimer": 300,
            "type": "grid",
            "renderType": "geojson",
            "dataSourceParameters": {
                "propertyName": "i",
                "commentCharacter": "#",
                "startLat": 90,
                "startLon": 0,
                "columns": 1024,
                "rows": 512,
                "minThreshold": 10,
                "deltaLat": -0.3515625,
                "deltaLon": 0.3515625
            },
            "defaultLegendProperty": "i",
            "url": "http://services.swpc.noaa.gov/text/aurora-nowcast-map.txt"
        }

For ESRI ASCII grid files, you only need to supply one property in the dataSourceParameters, i.e. "gridType": "esri".

More generally speaking the grid data source recognizes the following properties:

    export interface IGridDataSourceParameters {
        /**
         * Grid type, for example custom (default) or ESRI ASCII Grid
         */
        gridType: string,
        /**
         * Projection of the ESRI ASCII GRID. NOT USED YET
         */
        projection: string,
        /**
         * Property name of the cell value of the generated json.
         */
        propertyName: string,
        /**
         * Skip a comment line when it starts with this character
         */
        commentCharacter?: string,
        /**
         * Character that separates cells. Default is space.
         */
        separatorCharacter?: string,
        /**
         * Skip a number of lines from the start.
         */
        skipLines?: number,
        /**
         * Skip a number of lines after a comment block ends.
         */
        skipLinesAfterComment?: number,
        /**
         * Skip a number of spaces from the start of the line.
         */
        skipSpacesFromLine?: number,
        /**
         * Number of grid columns.
         */
        columns: number,
        /**
         * Number of grid rows.
         */
        rows: number,
        /**
         * Start latitude in degrees.
         */
        startLat: number,
        /**
         * Start longitude in degrees.
         */
        startLon: number,
        /**
         * Add delta latitude degrees after processing a grid cell.
         * NOTE: When the direction is negative, use a minus sign e.g. when counting from 90 to -90..
         */
        deltaLat: number,
        /**
         * Add delta longitude degrees degrees after processing a grid cell.
         */
        deltaLon: number,
        /**
         * Skip a first column, e.g. containing the latitude degree.
         */
        skipFirstColumn?: boolean,
        /**
         * Skip a first row, e.g. containing the longitude degree.
         */
        skipFirstRow?: boolean,
        /**
         * When the cell value is below this threshold, it is ignored.
         */
        minThreshold?: number,
        /**
        * When the cell value is above this threshold, it is ignored.
         */
        maxThreshold?: number,
        /**
         * The input values to be NoData in the output raster. Optional. Default is -9999.
         */
        noDataValue: number
    }

NightDayDataSource

This is a simple data source which requires no external URL, but generates a geojson polygon representing the day or night area. Configuration is simple:

        {
            "id": "Day",
            "title": "Day area",
            "refreshTimer": 60,
            "type": "daynight",
            "renderType": "geojson",
            "defaultLegendProperty": "day_intensity",
            "dataSourceParameters": {
                "showNight": false,
                "value": 0.02
            }
        }
    export interface INightDayDataSourceParameters {
        /**
         * Show the night (default) or day area.
         */
        showNight: boolean;
        /**
         * Set a property value for the area (default: intensity = 0)
         */
        value: number;
    }