ascii-grid: beta
Identify and Read an ARC/INFO ASCII Grid
motivation
I do a lot of client-side geoprocessing (see geoblaze) and wanted to add support for .asc files.
When I encountered large .asc files, I quickly ran out of memory because I was trying to load the whole file into memory.
This package was created to make it easy to read specific areas of an ASCII Grid in a memory-safe way and prevent my laptop from overheating.
usage
identify ascii grid files
isAsciiGrid identifies ASCII GRID files in the following formats: ArrayBuffer, Buffer, DataView, Promise, String, and Uint8Array
const isAsciiGrid = require("ascii-grid/is-ascii-grid");
const buffer = readFileSync('./test_data/michigan_lld/michigan_lld.asc');
isAsciiGrid({ data: buffer, debug: false });
parse ascii grid metadata
const parseAsciiGridMeta = require("ascii-grid/parse-ascii-grid-meta");
const buffer = readFileSync('./test_data/michigan_lld/michigan_lld.asc');
const metadata = parseAsciiGridMeta({ data: buffer, debug: false });
Reading Pixel Values
const parseAsciiGridData = require("ascii-grid/parse-ascii-grid-data");
const result = await parseAsciiGridData({ data: buffer, debug: true });
Reading Pixel Values within Bounding Box
You can specify a bounding box to read from by specifying the zero-based index
values of the first and last row, and first and last column for each row
const parseAsciiGridData = require("ascii-grid/parse-ascii-grid-data");
const result = await parseAsciiGridData({
data: buffer,
debug: true,
start_column: 2,
end_column: 10,
start_row: 1,
end_row: undefined
});