Skip to content

Surfer grid (.grd) file format implementation for Node.js.

License

Notifications You must be signed in to change notification settings

apdevelop/surfer-grid-file-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Surfer grid file format

Surfer grid (.grd) file format implementation for Node.js.

Surfer 6 grid (.grd) file formats (text and binary) implementation (reading and writing) for Node.js, without runtime dependencies.

Usage

Offline installation from local folder

Run tests npm test

Run in this repo folder to create tarball package npm pack

Run in application folder npm install <path/to/surfer-grid-file-format-0.1.0.tgz>

var Grid = require('surfer-grid-file-format');

// Creating grid from two-dimensional array
var grid = new Grid([
    [0, 1, 1, null],
    [2, 3, 5, 1],
    [1, 3, 2, 1]],
    0, 0, 30, 20);

console.log(grid.data[1][2]); // => 5
console.log(grid.rowCount()); // => 3
console.log(grid.columnCount()); // => 4
console.log(grid.blankedNodesCount()); // => 1

// Writing to file
grid.writeSync('./out.grd', Grid.BINARY);

// Reading from file
var gridFromFile = new Grid().readSync('./input.grd'); // Chained method call
console.log(gridFromFile.format); // => 'DSBB' which is Grid.BINARY format constant

API

Grid data represented in memory as two-dimensional array of 64-bit Number values. Blanked nodes has null value, but stored in file as special NoData value, 1.70141e+038.

TODOs

  • API improvements.
  • Asynchronous API.
  • NPM package.
  • API documentation.
  • Full support of Surfer 7 format.
  • Input data validation.

References

About

Surfer grid (.grd) file format implementation for Node.js.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published