1.0.34-alpha • Published 3 years ago

rgisf v1.0.34-alpha

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Rgisf

Custom GIS raster format and utilities for WebGIS

Rgisf is a npm package for loading and rendering GIS raster data.

Features

  • Adding custom renderers for a raster image/its bands
  • Render and save raster images
  • Generate a specific tile with the renderer
  • Generate and cache tiles at various zoom levels

Installation

You can install rgisf using npm:

npm install rgisf

Usage

Import the package:

    const Rgf = require('rgisf');

Loading data

  • From rgisf file

    a) Buffer:
    const rgf = new Rgf(buffer);

b) From file:

    const rgf = await Rgf.fromFile(path);

c) From url:

    const rgf = await Rgf.fromUrl(url);
  • From geotiff file

    Note: Currently, geotiff npm package is being used for loading and parsing geotiff data. a) From file:
    const rgf = await Rgf.fromGeoTiffFile(path);

b) From url:

    const rgf = await Rgf.fromGeoTiffUrl(url);

Updating renderer

  • Setting renderer

    const renderer = {
        type: 1, //Renderer.STRETCHED
        definition: {
            colorRamp: [[0, 0, 0, 255], [255, 255, 255, 255]]
        }
    }
    rgf.setRenderer(renderer)
    Currently, it supports two types of renderers: 1) Stretched 2) Classified
  • Stretched renderer

    Eg:

           {
               type: 1, //Renderer.STRETCHED
               definition: {
                   colorRamp: [
                       [0, 0, 0, 255],//[r,g,b,a]
                       [255, 255, 255, 255]
                   ]
               }
           }
      

You can add more colors to the color ramp array. It will be split at equal interval and applied across on the raster file.

  • Classified renderer

    Eg:

           {
               type: 2, //Renderer.CLASSIFIED
               definition: {
                   classes: [
                       {
                           min: 0,
                           max: 50,
                           color: [255, 16, 100, 255]
                       },
                       {
                           min: 50,
                           max: 75,
                           color: [255, 16, 16, 255]
                       },
                       {
                           min: 75,
                           max: 80,
                           color: [163, 19, 75, 255]
                       }
                   ]
               }
           }
      

Here, you can specify the color for the class and the range of value(min & max). Unspecified values(within any ranges) will be transparent.

Rendering

All the rendering related outputs will have the applied renderer. To get rendered datauri,

const img = rgf.toDataUrl()

To save it as a PNG,

await rgf.saveAsPng(path)

To get specfic tile for the given x, y, z

const canvas = await rgf.getTileImage();
const dataUrl = canvas.toDataURL();

To save a specific tile as PNG,

await rgf.saveTileAsPng(path);

To generate and save tiles for specified zoom levels,

const z1 = 5;
const z2 = 12;
await rgf.generateTiles(z1, z2, tileCacheDir);
1.0.33-alpha

3 years ago

1.0.31-alpha

3 years ago

1.0.32-alpha

3 years ago

1.0.34-alpha

3 years ago

1.0.30-alpha

3 years ago

1.0.28-alpha

3 years ago

1.0.27-alpha

3 years ago

1.0.29-alpha

3 years ago

1.0.26-alpha

3 years ago

1.0.25-alpha

3 years ago

1.0.23-alpha

3 years ago

1.0.24-alpha

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago