mrf

1.0.1 • Public • Published

mrf: beta

Read Meta Raster Format Files (e.g. .mrf, .idx, .lrc, .data)

install

npm install mrf

Usage

loading the library

You can load the library in three different ways.

CommonJS Require

If you are using CommonJS, you can require the library like so:

const mrf = require("mrf");

Or import a specific function like so:

const { parseIDX } = require("mrf");

ES6 Modules

If you are using ES6 Modules, you can import like so:

import mrf from 'mrf';

Or import a specific function like so:

import { parseIDX } from "mrf";

Script Tag

<script src="https://unpkg.com/mrf"></script>

parsing .mrf files

The .mrf file includes the metadata about your project. You can parse it by calling parseMRF, as in the example below:

import { readFileSync } from 'fs';
import { parseMRF } from 'mrf';

const buffer = readFileSync("./example.mrf");
const result = parseMRF(buffer);

result is a JSON serializable object that looks like the following:

{
  "area": 50362506,
  "height": 7587,
  "width": 6638,
  "depth": 1,
  "numBands": 4,
  "pageHeight": 512,
  "pageWidth": 512,
  "pageDepth": 1,
  "pageBands": 1,
  "compression": "LERC",
  "rsets": {
    "model": "uniform",
    "scale": 2
  },
  "xmin": 601135,
  "ymin": 3422859,
  "xmax": 607773,
  "ymax": 3430446,
  "projection": "PROJCS[\"NAD83 / UTM zone 16N\",GEOGCS[...]]",
  "order": "band",
  "overviews": [
    {
      "height": 3794,
      "heightInPages": 8,
      "pages": 224,
      "offset": 780,
      "width": 3319,
      "widthInPages": 7,
      "scale": {
        "height": 1.999736425935688,
        "width": 2
      }
    },
    /*
    .
    .
    .
    */
  ]
}

There are other properties available that deal with time and build options. Please see the examples.

parsing .idx files

Index files list the offset and length of each tile in binary format. You can parse this information like so:

import { readFileSync } from 'fs';
import { parseIDX } from 'mrf';

const buffer = readFileSync("test.idx");
const result = parseIDX(buffer);

result is an array of objects that looks like the following:

[
  { "offset": 0, "length": 181646 },
  { "offset": 35326744, "length": 178797 },
  { "offset": 70080116, "length": 171538 },
  // 1085 more items
]

Known Limitations

  • Currently only supports LERC Compression and .lrc data files

References:

Dependencies (11)

Dev Dependencies (18)

Package Sidebar

Install

npm i mrf

Weekly Downloads

8

Version

1.0.1

License

CC0-1.0

Unpacked Size

52.4 kB

Total Files

13

Last publish

Collaborators

  • danieljdufour