s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
115 lines • 4.07 kB
TypeScript
import type { FeatureIterator, ReaderInputs } from '..';
import type { MValue, Properties, VectorFeature } from '../../geometry';
/** The kind of data that can be stored in a NetCDF file */
export type CDFValue = string | number | number[];
/** The kind of attributes that can be stored in a NetCDF file. Similar to a GeoJSON Properties object */
export type CDFAttributes = Record<string, CDFValue>;
/** Track the dimension and its max value (can be infinity) */
export interface CDFDimension {
/** index of the dimension */
index: number;
/** name of the dimension */
name: string;
/** size of the dimension */
size: number;
}
/** Track information about the dimensions, which is "unlimited" dimension, and variable sizes */
export interface CDFRecordDimension {
/** Length of the record dimension sum of the varSize's of all the record variables */
size: number;
id?: number;
name?: string;
recordStep?: number;
}
/** A NetCDF variable */
export interface CDFVariable {
/** name of the variable */
name: string;
/** Array with the dimension IDs of the variable */
dimensions: CDFDimension[];
/** Array with the attributes of the variable */
attributes: CDFAttributes;
/** type of the variable */
type: CDFDataType;
/** size of the variable */
size: number;
/** offset where of the variable begins */
offset: number;
/** True if is a record variable, false otherwise (unlimited size) */
record: boolean;
}
/** Enum of the NetCDF data types available */
export declare enum CDFDataType {
/** Byte size (1 byte) */
BYTE = 1,
/** Char size (1 byte) */
CHAR = 2,
/** Short size (2 bytes) */
SHORT = 3,
/** Integer size (4 bytes) */
INT = 4,
/** Float size (4 bytes) */
FLOAT = 5,
/** Double size (8 bytes) */
DOUBLE = 6
}
/** User defined options on how to parse the CSV file */
export interface NetCDFReaderOptions {
/** If provided the lookup of the longitude [Default='lon'] */
lonKey?: string;
/** If provided the lookup of the latitude [Default='lat'] */
latKey?: string;
/** If provided the lookup for the height value [Default=undefined] */
heightKey?: string;
/** List of fields to include in the feature properties */
propFields?: string[];
}
/**
* # NetCDF v3.x Reader
*
* ## Description
* Read the NetCDF v3.x file format
* [See specification](https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html)
* Implements the {@link FeatureIterator} interface
*
* ## Usage
* ```ts
* import { NetCDFReader } from 's2-tools';
* import { FileReader } from 's2-tools/file';
*
* const reader = new NetCDFReader(new FileReader('./data.nc'));
* for (const feature of reader) {
* console.log(feature);
* }
* ```
*/
export declare class NetCDFReader<M = Record<string, unknown>, D extends MValue = MValue, P extends Properties = Properties> implements FeatureIterator<M, D, P> {
#private;
private reader;
readonly recordDimension: CDFRecordDimension;
/** List of dimensions */
readonly dimensions: CDFDimension[];
/** List of global attributes */
globalAttributes: CDFAttributes;
/** List of variables */
readonly variables: CDFVariable[];
/** Describes if offsets are 32 or 64 bits */
readonly is64: boolean;
/**
* @param input - The data as either a buffer or file reader
* @param options - User defined options to apply when reading the NetCDF file
*/
constructor(input: ReaderInputs, options?: NetCDFReaderOptions);
/**
* Retrieves the data for a given variable
* @param variableName - Name of the variable to search or variable object
* @returns The variable values
*/
getDataVariable(variableName: string): CDFValue[] | undefined;
/**
* Generator to iterate over each (Geo|S2)JSON object in the file
* @yields {VectorFeature}
*/
[Symbol.asyncIterator](): AsyncGenerator<VectorFeature<M, D, P>>;
}
//# sourceMappingURL=index.d.ts.map