UNPKG

gdal-async

Version:

Bindings to GDAL (Geospatial Data Abstraction Library) with full async support

1,973 lines (1,761 loc) 213 kB
import * as stream from 'stream'; export type Color = { c1: number; c2: number; c3: number; c4: number; } export type ContourOptions = { src: RasterBand; dst: Layer; offset?: number; interval?: number; fixedLevels?: number[]; nodata?: number; idField?: number; elevField?: number; progress_cb?: ProgressCb; } export type CreateOptions = { progress_cb?: ProgressCb; } export type FillOptions = { src: RasterBand; mask?: RasterBand; searchDist: number; smoothingIterations?: number; } export type MDArrayOptions = { origin: number[]; span: number[]; stride?: number[]; data_type?: string; data?: TypedArray; _offset?: number; } export type PolygonizeOptions = { src: RasterBand; dst: Layer; mask?: RasterBand; pixValField: number; connectedness?: number; useFloats?: boolean; progress_cb?: ProgressCb; } export type ProgressCb = ( complete: number, msg: string ) => void export type ProgressOptions = { progress_cb: ProgressCb; } export type ReadOptions = { buffer_width?: number; buffer_height?: number; type?: string; pixel_space?: number; line_space?: number; resampling?: string; progress_cb?: ProgressCb; offset?: number; } export type ReprojectOptions = { src: Dataset; dst: Dataset; s_srs: SpatialReference; t_srs: SpatialReference; resampling?: string; cutline?: Geometry; srcBands?: number[]; dstBands?: number[]; srcAlphaBand?: number; dstAlphaBand?: number; srcNodata?: number; dstNodata?: number; blend?: number; memoryLimit?: number; maxError?: number; multi?: boolean; options?: object; progress_cb?: ProgressCb; } export type SieveOptions = { src: RasterBand; dst: RasterBand; mask?: RasterBand; threshold: number; connectedness?: number; progress_cb?: ProgressCb; } export type TypedArray = Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array export type UtilOptions = { progress_cb?: ProgressCb; } export type VSIStat = { dev: number; mode: number; nlink: number; uid: number; gid: number; rdev: number; blksize: number; ino: number; size: number; blocks: number; atime: Date; mtime: Date; ctime: Date; } export type VSIStat64 = { dev: BigInt; mode: BigInt; nlink: BigInt; uid: BigInt; gid: BigInt; rdev: BigInt; blksize: BigInt; ino: BigInt; size: BigInt; blocks: BigInt; atime: Date; mtime: Date; ctime: Date; } export type WarpOptions = { src: Dataset; s_srs: SpatialReference; t_srs: SpatialReference; maxError?: number; } export type WarpOutput = { rasterSize: xyz; geoTransform: number[]; } export type WriteOptions = { buffer_width?: number; buffer_height?: number; pixel_space?: number; line_space?: number; progress_cb?: ProgressCb; offset?: number; } export type callback<T> = (err: Error, obj: T) => void export type forEachCb<T> = (obj: T, idx: number) => boolean|void export type mapCb<T,U> = (obj: T, index: number) => U export type stats = { min: number; max: number; mean: number; std_dev: number; } export type units = { units: string; value: number; } export interface CalcOptions { convertNoData?: boolean; } export interface RasterReadableOptions extends stream.ReadableOptions { blockOptimize?: boolean; convertNoData?: boolean; type?: new (len: number) => TypedArray; } export interface RasterTransformOptions extends stream.TransformOptions { fn: Function; type: new (len: number) => TypedArray; } export interface RasterWritableOptions extends stream.WritableOptions { blockOptimize?: boolean; convertNoData?: boolean; } export interface fieldValue { key: string, value: any } export interface xyz { x: number; y: number; z?: number; } /** * Error level: Debug * * @final * @property gdal.CE_Debug * @type {number} */ export const CE_Debug: number /** * Error level: Failure * * @final * @property gdal.CE_Failure * @type {number} */ export const CE_Failure: number /** * Error level: Fatal * * @final * @property gdal.CE_Fatal * @type {number} */ export const CE_Fatal: number /** * Error level: (no error) * * @final * @property gdal.CE_None * @type {number} */ export const CE_None: number /** * Error level: Warning * * @final * @property gdal.CE_Warning * @type {number} */ export const CE_Warning: number /** * @final * @property gdal.CPLE_AppDefined * @type {number} */ export const CPLE_AppDefined: number /** * @final * @property gdal.CPLE_AssertionFailed * @type {number} */ export const CPLE_AssertionFailed: number /** * @final * @property gdal.CPLE_FileIO * @type {number} */ export const CPLE_FileIO: number /** * @final * @property gdal.CPLE_IllegalArg * @type {number} */ export const CPLE_IllegalArg: number /** * @final * @property gdal.CPLE_NoWriteAccess * @type {number} */ export const CPLE_NoWriteAccess: number /** * @final * @property gdal.CPLE_None * @type {number} */ export const CPLE_None: number /** * @final * @property gdal.CPLE_NotSupported * @type {number} */ export const CPLE_NotSupported: number /** * @final * @property gdal.CPLE_OpenFailed * @type {number} */ export const CPLE_OpenFailed: number /** * @final * @property gdal.CPLE_OutOfMemory * @type {number} */ export const CPLE_OutOfMemory: number /** * @final * @property gdal.CPLE_UserInterrupt * @type {number} */ export const CPLE_UserInterrupt: number /** * @final * @property gdal.CPLE_objectNull * @type {number} */ export const CPLE_objectNull: number /** * @final * @property gdal.DCAP_CREATE * @type {string} */ export const DCAP_CREATE: string /** * @final * @property gdal.DCAP_CREATECOPY * @type {string} */ export const DCAP_CREATECOPY: string /** * @final * @property gdal.DCAP_VIRTUALIO * @type {string} */ export const DCAP_VIRTUALIO: string /** * @final * @property gdal.DIM_HORIZONTAL_X * @type {string} */ export const DIM_HORIZONTAL_X: string /** * @final * @property gdal.DIM_HORIZONTAL_Y * @type {string} */ export const DIM_HORIZONTAL_Y: string /** * @final * @property gdal.DIM_PARAMETRIC * @type {string} */ export const DIM_PARAMETRIC: string /** * @final * @property gdal.DIM_TEMPORAL * @type {string} */ export const DIM_TEMPORAL: string /** * @final * @property gdal.DIM_VERTICAL * @type {string} */ export const DIM_VERTICAL: string /** * @final * @property gdal.DIR_DOWN * @type {string} */ export const DIR_DOWN: string /** * @final * @property gdal.DIR_EAST * @type {string} */ export const DIR_EAST: string /** * @final * @property gdal.DIR_FUTURE * @type {string} */ export const DIR_FUTURE: string /** * @final * @property gdal.DIR_NORTH * @type {string} */ export const DIR_NORTH: string /** * @final * @property gdal.DIR_PAST * @type {string} */ export const DIR_PAST: string /** * @final * @property gdal.DIR_SOUTH * @type {string} */ export const DIR_SOUTH: string /** * @final * @property gdal.DIR_UP * @type {string} */ export const DIR_UP: string /** * @final * @property gdal.DIR_WEST * @type {string} */ export const DIR_WEST: string /** * @final * @property gdal.DMD_CREATIONDATATYPES * @type {string} */ export const DMD_CREATIONDATATYPES: string /** * @final * @property gdal.DMD_CREATIONOPTIONLIST * @type {string} */ export const DMD_CREATIONOPTIONLIST: string /** * @final * @property gdal.DMD_EXTENSION * @type {string} */ export const DMD_EXTENSION: string /** * @final * @property gdal.DMD_HELPTOPIC * @type {string} */ export const DMD_HELPTOPIC: string /** * @final * @property gdal.DMD_LONGNAME * @type {string} */ export const DMD_LONGNAME: string /** * @final * @property gdal.DMD_MIMETYPE * @type {string} */ export const DMD_MIMETYPE: string /** * @final * @property gdal.GCI_AlphaBand * @type {string} */ export const GCI_AlphaBand: string /** * @final * @property gdal.GCI_BlackBand * @type {string} */ export const GCI_BlackBand: string /** * @final * @property gdal.GCI_BlueBand * @type {string} */ export const GCI_BlueBand: string /** * @final * @property gdal.GCI_CyanBand * @type {string} */ export const GCI_CyanBand: string /** * @final * @property gdal.GCI_GrayIndex * @type {string} */ export const GCI_GrayIndex: string /** * @final * @property gdal.GCI_GreenBand * @type {string} */ export const GCI_GreenBand: string /** * @final * @property gdal.GCI_HueBand * @type {string} */ export const GCI_HueBand: string /** * @final * @property gdal.GCI_LightnessBand * @type {string} */ export const GCI_LightnessBand: string /** * @final * @property gdal.GCI_MagentaBand * @type {string} */ export const GCI_MagentaBand: string /** * @final * @property gdal.GCI_PaletteIndex * @type {string} */ export const GCI_PaletteIndex: string /** * @final * @property gdal.GCI_RedBand * @type {string} */ export const GCI_RedBand: string /** * @final * @property gdal.GCI_SaturationBand * @type {string} */ export const GCI_SaturationBand: string /** * @final * @property gdal.GCI_Undefined * @type {string} */ export const GCI_Undefined: string /** * @final * @property gdal.GCI_YCbCr_CbBand * @type {string} */ export const GCI_YCbCr_CbBand: string /** * @final * @property gdal.GCI_YCbCr_CrBand * @type {string} */ export const GCI_YCbCr_CrBand: string /** * @final * @property gdal.GCI_YCbCr_YBand * @type {string} */ export const GCI_YCbCr_YBand: string /** * @final * @property gdal.GCI_YellowBand * @type {string} */ export const GCI_YellowBand: string /** * Eight bit unsigned integer * @final * @property gdal.GDT_Byte * @type {string} */ export const GDT_Byte: string /** * Complex Float32 * @final * @property gdal.GDT_CFloat32 * @type {string} */ export const GDT_CFloat32: string /** * Complex Float64 * @final * @property gdal.GDT_CFloat64 * @type {string} */ export const GDT_CFloat64: string /** * Complex Int16 * @final * @property gdal.GDT_CInt16 * @type {string} */ export const GDT_CInt16: string /** * Complex Int32 * @final * @property gdal.GDT_CInt32 * @type {string} */ export const GDT_CInt32: string /** * Thirty two bit floating point * @final * @property gdal.GDT_Float32 * @type {string} */ export const GDT_Float32: string /** * Sixty four bit floating point * @final * @property gdal.GDT_Float64 * @type {string} */ export const GDT_Float64: string /** * Sixteen bit signed integer * @final * @property gdal.GDT_Int16 * @type {string} */ export const GDT_Int16: string /** * Thirty two bit signed integer * @final * @property gdal.GDT_Int32 * @type {string} */ export const GDT_Int32: string /** * Sixteen bit unsigned integer * @final * @property gdal.GDT_UInt16 * @type {string} */ export const GDT_UInt16: string /** * Thirty two bit unsigned integer * @final * @property gdal.GDT_UInt32 * @type {string} */ export const GDT_UInt32: string /** * Unknown or unspecified type * @final * @property gdal.GDT_Unknown * @type {string} */ export const GDT_Unknown: string /** * String extended type for MDArrays (GDAL >= 3.1) * @final * @property gdal.GEDTC_Compound * @type {string} */ export const GEDTC_Compound: string /** * String extended type for MDArrays (GDAL >= 3.1) * @final * @property gdal.GEDTC_String * @type {string} */ export const GEDTC_String: string /** * CMYK * @final * @property gdal.GPI_CMYK * @type {string} */ export const GPI_CMYK: string /** * Grayscale, only c1 defined * @final * @property gdal.GPI_Gray * @type {string} */ export const GPI_Gray: string /** * HLS, c4 is not defined * @final * @property gdal.GPI_HLS * @type {string} */ export const GPI_HLS: string /** * RGBA, alpha in c4 * @final * @property gdal.GPI_RGB * @type {string} */ export const GPI_RGB: string /** * @final * @property gdal.GRA_Average * @type {string} */ export const GRA_Average: string /** * @final * @property gdal.GRA_Bilinear * @type {string} */ export const GRA_Bilinear: string /** * @final * @property gdal.GRA_Cubic * @type {string} */ export const GRA_Cubic: string /** * @final * @property gdal.GRA_CubicSpline * @type {string} */ export const GRA_CubicSpline: string /** * @final * @property gdal.GRA_Lanczos * @type {string} */ export const GRA_Lanczos: string /** * @final * @property gdal.GRA_Mode * @type {string} */ export const GRA_Mode: string /** * @final * @property gdal.GRA_NearestNeighbor * @type {string} */ export const GRA_NearestNeighbor: string /** * @final * @property gdal.ODrCCreateDataSource * @type {string} */ export const ODrCCreateDataSource: string /** * @final * @property gdal.ODrCDeleteDataSource * @type {string} */ export const ODrCDeleteDataSource: string /** * @final * @property gdal.ODsCCreateGeomFieldAfterCreateLayer * @type {string} */ export const ODsCCreateGeomFieldAfterCreateLayer: string /** * @final * @property gdal.ODsCCreateLayer * @type {string} */ export const ODsCCreateLayer: string /** * @final * @property gdal.ODsCDeleteLayer * @type {string} */ export const ODsCDeleteLayer: string /** * @final * @property gdal.OFTBinary * @type {string} */ export const OFTBinary: string /** * @final * @property gdal.OFTDate * @type {string} */ export const OFTDate: string /** * @final * @property gdal.OFTDateTime * @type {string} */ export const OFTDateTime: string /** * @final * @property gdal.OFTInteger * @type {string} */ export const OFTInteger: string /** * @final * @property gdal.OFTInteger64 * @type {string} */ export const OFTInteger64: string /** * @final * @property gdal.OFTInteger64List * @type {string} */ export const OFTInteger64List: string /** * @final * @property gdal.OFTIntegerList * @type {string} */ export const OFTIntegerList: string /** * @final * @property gdal.OFTReal * @type {string} */ export const OFTReal: string /** * @final * @property gdal.OFTRealList * @type {string} */ export const OFTRealList: string /** * @final * @property gdal.OFTString * @type {string} */ export const OFTString: string /** * @final * @property gdal.OFTStringList * @type {string} */ export const OFTStringList: string /** * @final * @property gdal.OFTTime * @type {string} */ export const OFTTime: string /** * @final * @property gdal.OFTWideString * @type {string} */ export const OFTWideString: string /** * @final * @property gdal.OFTWideStringList * @type {string} */ export const OFTWideStringList: string /** * @final * @property gdal.OJLeft * @type {string} */ export const OJLeft: string /** * @final * @property gdal.OJRight * @type {string} */ export const OJRight: string /** * @final * @property gdal.OJUndefined * @type {string} */ export const OJUndefined: string /** * @final * @property gdal.OLCAlterFieldDefn * @type {string} */ export const OLCAlterFieldDefn: string /** * @final * @property gdal.OLCCreateField * @type {string} */ export const OLCCreateField: string /** * @final * @property gdal.OLCCreateGeomField * @type {string} */ export const OLCCreateGeomField: string /** * @final * @property gdal.OLCDeleteFeature * @type {string} */ export const OLCDeleteFeature: string /** * @final * @property gdal.OLCDeleteField * @type {string} */ export const OLCDeleteField: string /** * @final * @property gdal.OLCFastFeatureCount * @type {string} */ export const OLCFastFeatureCount: string /** * @final * @property gdal.OLCFastGetExtent * @type {string} */ export const OLCFastGetExtent: string /** * @final * @property gdal.OLCFastSetNextByIndex * @type {string} */ export const OLCFastSetNextByIndex: string /** * @final * @property gdal.OLCFastSpatialFilter * @type {string} */ export const OLCFastSpatialFilter: string /** * @final * @property gdal.OLCIgnoreFields * @type {string} */ export const OLCIgnoreFields: string /** * @final * @property gdal.OLCRandomRead * @type {string} */ export const OLCRandomRead: string /** * @final * @property gdal.OLCRandomWrite * @type {string} */ export const OLCRandomWrite: string /** * @final * @property gdal.OLCReorderFields * @type {string} */ export const OLCReorderFields: string /** * @final * @property gdal.OLCSequentialWrite * @type {string} */ export const OLCSequentialWrite: string /** * @final * @property gdal.OLCStringsAsUTF8 * @type {string} */ export const OLCStringsAsUTF8: string /** * @final * @property gdal.OLCTransactions * @type {string} */ export const OLCTransactions: string /** * GDAL library - system library (false) or bundled (true) * * @final * @for gdal * @property gdal.bundled * @type {boolean} */ export const bundled: boolean /** * The collection of all drivers registered with GDAL * * @final * @for gdal * @property gdal.drivers * @type {gdal.GDALDrivers} */ export const drivers: GDALDrivers /** * Should a warning be emitted to stderr when a synchronous operation * is blocking the event loop, can be safely disabled unless * the user application needs to remain responsive at all times * Use `(gdal as any).eventLoopWarning = false` to set the value from TypeScript * * @for gdal * @property gdal.eventLoopWarning * @type {boolean} */ export let eventLoopWarning: boolean /** * @attribute lastError * @type {object} */ export let lastError: object /** * GDAL version (not the binding version) * * @final * @for gdal * @property gdal.version * @type {string} */ export const version: string /** * @final * * The `wkb25DBit` constant can be used to convert between 2D types to 2.5D * types * * @example * ``` * // 2 -> 2.5D * wkbPoint25D = gdal.wkbPoint | gdal.wkb25DBit * * // 2.5D -> 2D (same as wkbFlatten()) * wkbPoint = gdal.wkbPoint25D & (~gdal.wkb25DBit)``` * * @property gdal.wkb25DBit * @type {number} */ export const wkb25DBit: number /** * @final * @property gdal.wkbCircularString * @type {number} */ export const wkbCircularString: number /** * @final * @property gdal.wkbCompoundCurve * @type {number} */ export const wkbCompoundCurve: number /** * @final * @property gdal.wkbGeometryCollection * @type {number} */ export const wkbGeometryCollection: number /** * @final * @property gdal.wkbGeometryCollection25D * @type {number} */ export const wkbGeometryCollection25D: number /** * @final * @property gdal.wkbLineString * @type {number} */ export const wkbLineString: number /** * @final * @property gdal.wkbLineString25D * @type {number} */ export const wkbLineString25D: number /** * @final * @property gdal.wkbLinearRing * @type {string} */ export const wkbLinearRing: string /** * @final * @property gdal.wkbLinearRing25D * @type {number} */ export const wkbLinearRing25D: number /** * @final * @property gdal.wkbMultiCurve * @type {number} */ export const wkbMultiCurve: number /** * @final * @property gdal.wkbMultiLineString * @type {number} */ export const wkbMultiLineString: number /** * @final * @property gdal.wkbMultiLineString25D * @type {number} */ export const wkbMultiLineString25D: number /** * @final * @property gdal.wkbMultiPoint * @type {number} */ export const wkbMultiPoint: number /** * @final * @property gdal.wkbMultiPoint25D * @type {number} */ export const wkbMultiPoint25D: number /** * @final * @property gdal.wkbMultiPolygon * @type {number} */ export const wkbMultiPolygon: number /** * @final * @property gdal.wkbMultiPolygon25D * @type {number} */ export const wkbMultiPolygon25D: number /** * @final * @property gdal.wkbNDR * @type {string} */ export const wkbNDR: string /** * @final * @property gdal.wkbNone * @type {number} */ export const wkbNone: number /** * @final * @property gdal.wkbPoint * @type {number} */ export const wkbPoint: number /** * @final * @property gdal.wkbPoint25D * @type {number} */ export const wkbPoint25D: number /** * @final * @property gdal.wkbPolygon * @type {number} */ export const wkbPolygon: number /** * @final * @property gdal.wkbPolygon25D * @type {number} */ export const wkbPolygon25D: number /** * @final * @property gdal.wkbUnknown * @type {number} */ export const wkbUnknown: number /** * SFSQL 1.2 and ISO SQL/MM Part 3 extended dimension (Z&M) WKB types. * * @final * @property gdal.wkbVariantIso * @type {string} */ export const wkbVariantIso: string /** * Old-style 99-402 extended dimension (Z) WKB types. * Synonymous with 'wkbVariantOldOgc' (gdal >= 2.0) * * @final * @property gdal.wkbVariantOgc * @type {string} */ export const wkbVariantOgc: string /** * Old-style 99-402 extended dimension (Z) WKB types. * Synonymous with 'wkbVariantOgc' (gdal < 2.0) * * @final * @property gdal.wkbVariantOldOgc * @type {string} */ export const wkbVariantOldOgc: string /** * @final * @property gdal.wkbXDR * @type {string} */ export const wkbXDR: string /** * Compute a new output band as a pixel-wise function of given input bands * * This is an alternative implementation of `gdal_calc.py` * * It is fully async and reading and decoding of input and output bands happen * in separate background threads for each band as long as they are in separate datasets. * * The main bottleneck is the passed function `fn` which must always run on the main Node.js/V8 thread. * This is a fundamental Node.js/V8 limitation that is impossible to overcome. * * This function is not to be used in server code that must remain responsive at all times. * It does not directly block the event loop, but it is very CPU-heavy and cannot * run parallel to other instances of itself. If multiple instances run in parallel, they * will all compete for the main thread, executing `fn` on the incoming data chunks on turn by turn basis. * * There is no sync version * * @for gdal * @method calcAsync * @param {Record<string, gdal.RasterBand>} inputs An object containing all the input bands * @param {gdal.RasterBand} output Output raster band * @param {(...args: number[]) => number} fn Function to apply on all pixels, it must have the same number of arguments as there are input bands * @param {CalcOptions} [options] Options * @param {boolean} [options.convertNoData=false] Input bands will have their NoData pixels converted to NaN and a NaN output value of the given function will be converted to a NoData pixel, provided that the output raster band has its `gdal.RasterBand.noDataValue` set * @return {Promise<void>} * @static * * @example * ``` * const T2m = await gdal.openAsync('TEMP_2M.tiff')); * const D2m = await gdal.openAsync('DEWPOINT_2M.tiff')); * const size = await T2m.rasterSizeAsync * const cloudBase = await gdal.openAsync('CLOUDBASE.tiff', 'w', 'GTiff', * size.x, size.y, 1, gdal.GDT_Float64); * * (await cloudBase.bands.getAsync(1)).noDataValue = -1e38 * // Espy's estimation for cloud base height * const espyFn = (t, td) => 125 * (t - td); * * await calcAsync({ * t: await T2m.bands.getAsync(1), * td: await D2m.bands.getAsync(1) * }, cloudBase.bands.getAsync(1), espyFn, { convertNoData: true }); * ``` */ export function calcAsync(inputs: Record<string, RasterBand>, output: RasterBand, fn: (...args: number[]) => number, options?: CalcOptions): Promise<void> /** * Compute checksum for image region. * * @throws Error * @method checksumImage * @static * @for gdal * @param {gdal.RasterBand} src * @param {number} [x=0] * @param {number} [y=0] * @param {number} [w=src.width] * @param {number} [h=src.height] * @return {number} */ export function checksumImage(src: RasterBand, x?: number, y?: number, w?: number, h?: number): number /** * Compute checksum for image region. * * @throws Error * @method checksumImageAsync * @static * @for gdal * @param {gdal.RasterBand} src * @param {number} [x=0] * @param {number} [y=0] * @param {number} [w=src.width] * @param {number} [h=src.height] * @param {callback<number>} [callback=undefined] {{{cb}}} * @return {number} * @return {Promise<number>} */ export function checksumImageAsync(src: RasterBand, x?: number, y?: number, w?: number, h?: number, callback?: callback<number>): Promise<number> /** * Create vector contours from raster DEM. * * This algorithm will generate contour vectors for the input raster band on the * requested set of contour levels. The vector contours are written to the * passed in vector layer. Also, a NODATA value may be specified to identify * pixels that should not be considered in contour line generation. * * @throws Error * @method contourGenerate * @static * @for gdal * @param {ContourOptions} options * @param {gdal.RasterBand} options.src * @param {gdal.Layer} options.dst * @param {number} [options.offset=0] The "offset" relative to which contour intervals are applied. This is normally zero, but could be different. To generate 10m contours at 5, 15, 25, ... the offset would be 5. * @param {number} [options.interval=100] The elevation interval between contours generated. * @param {number[]} [options.fixedLevels] A list of fixed contour levels at which contours should be generated. Overrides interval/base options if set. * @param {number} [options.nodata] The value to use as a "nodata" value. That is, a pixel value which should be ignored in generating contours as if the value of the pixel were not known. * @param {number} [options.idField] A field index to indicate where a unique id should be written for each feature (contour) written. * @param {number} [options.elevField] A field index to indicate where the elevation value of the contour should be written. * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} */ export function contourGenerate(options: ContourOptions): void /** * Create vector contours from raster DEM. * {{{async}}} * * This algorithm will generate contour vectors for the input raster band on the * requested set of contour levels. The vector contours are written to the * passed in vector layer. Also, a NODATA value may be specified to identify * pixels that should not be considered in contour line generation. * * @throws Error * @method contourGenerateAsync * @static * @for gdal * @param {ContourOptions} options * @param {gdal.RasterBand} options.src * @param {gdal.Layer} options.dst * @param {number} [options.offset=0] The "offset" relative to which contour intervals are applied. This is normally zero, but could be different. To generate 10m contours at 5, 15, 25, ... the offset would be 5. * @param {number} [options.interval=100] The elevation interval between contours generated. * @param {number[]} [options.fixedLevels] A list of fixed contour levels at which contours should be generated. Overrides interval/base options if set. * @param {number} [options.nodata] The value to use as a "nodata" value. That is, a pixel value which should be ignored in generating contours as if the value of the pixel were not known. * @param {number} [options.idField] A field index to indicate where a unique id should be written for each feature (contour) written. * @param {number} [options.elevField] A field index to indicate where the elevation value of the contour should be written. * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @param {callback<void>} [callback=undefined] {{{cb}}} * @return {Promise<void>} */ export function contourGenerateAsync(options: ContourOptions, callback?: callback<void>): Promise<void> /** * Convert decimal degrees to degrees, minutes, and seconds string * * @for gdal * @static * @method decToDMS * @param {number} angle * @param {string} axis `"lat"` or `"long"` * @param {number} [precision=2] * @return {string} A string nndnn'nn.nn'"L where n is a number and L is either * N or E */ export function decToDMS(angle: number, axis: string, precision?: number): string /** * Fill raster regions by interpolation from edges. * * @throws Error * @method fillNodata * @static * @for gdal * @param {FillOptions} options * @param {gdal.RasterBand} options.src This band to be updated in-place. * @param {gdal.RasterBand} [options.mask] Mask band * @param {number} options.searchDist The maximum distance (in pixels) that the algorithm will search out for values to interpolate. * @param {number} [options.smoothingIterations=0] The number of 3x3 average filter smoothing iterations to run after the interpolation to dampen artifacts. */ export function fillNodata(options: FillOptions): void /** * Fill raster regions by interpolation from edges. * {{{async}}} * * @throws Error * @method fillNodataAsync * @static * @for gdal * @param {FillOptions} options * @param {gdal.RasterBand} options.src This band to be updated in-place. * @param {gdal.RasterBand} [options.mask] Mask band * @param {number} options.searchDist The maximum distance (in pixels) that the algorithm will search out for values to interpolate. * @param {number} [options.smoothingIterations=0] The number of 3x3 average filter smoothing iterations to run after the interpolation to dampen artifacts. * @param {callback<void>} [callback=undefined] {{{cb}}} * @return {Promise<void>} */ export function fillNodataAsync(options: FillOptions, callback?: callback<void>): Promise<void> /** * Returns a TypedArray (https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView#Typed_array_subclasses) constructor from a GDAL data type * * @example * ``` * const array = new (gdal.fromDataType(band.dataType))(band.size.x * band.size.y) * ```` * * @for gdal * @method fromDataType * @throws TypeError * @param {string|null} dataType * @return {new (len: number) => TypedArray} */ export function fromDataType(dataType: string|null): new (len: number) => TypedArray /** * Library version of gdalinfo * * @example * const ds = gdal.open('input.tif') * const output = gdal.info('/vsimem/temp.tif') * * @throws Error * @method info * @for gdal * @static * @param {gdal.Dataset} dataset * @param {string[]} [args] array of CLI options for gdalinfo * @return {string} */ export function info(dataset: Dataset, args?: string[]): string /** * Library version of gdalinfo * {{{async}}} * * @example * const ds = gdal.open('input.tif') * const output = gdal.info('/vsimem/temp.tif') * @throws Error * * @method infoAsync * @for gdal * @static * @param {gdal.Dataset} dataset * @param {string[]} [args] array of CLI options for gdalinfo * @param {callback<string>} [callback=undefined] {{{cb}}} * @return {Promise<string>} */ export function infoAsync(dataset: Dataset, args?: string[], callback?: callback<string>): Promise<string> /** * Creates or opens a dataset. Dataset should be explicitly closed with `dataset.close()` method if opened in `"w"` mode to flush any changes. Otherwise, datasets are closed when (and if) node decides to garbage collect them. * * @example * ``` * var dataset = gdal.open('./data.shp');``` * * @example * ``` * var dataset = gdal.open(fs.readFileSync('./data.shp'));``` * * @for gdal * @throws Error * @method open * @static * @param {string|Buffer} path Path to dataset or in-memory Buffer to open * @param {string} [mode="r"] The mode to use to open the file: `"r"`, `"r+"`, or `"w"` * @param {string|string[]} [drivers] Driver name, or list of driver names to attempt to use. * * @param {number} [x_size] Used when creating a raster dataset with the `"w"` mode. * @param {number} [y_size] Used when creating a raster dataset with the `"w"` mode. * @param {number} [band_count] Used when creating a raster dataset with the `"w"` mode. * @param {string} [data_type] Used when creating a raster dataset with the `"w"` mode. * @param {string[]|object} [creation_options] Used when creating a dataset with the `"w"` mode. * * @return {Dataset} */ export function open(path: string|Buffer, mode?: string, drivers?: string|string[], x_size?: number, y_size?: number, band_count?: number, data_type?: string, creation_options?: string[]|object): Dataset /** * TypeScript shorthand version with callback and no optional arguments * * @for gdal * @method openAsync * @static * @param {string|Buffer} path Path to dataset or in-memory Buffer to open * @param {callback<Dataset>} callback {{{cb}}} * @return {void} */ export function openAsync(path: string|Buffer, callback: callback<Dataset>): void /** * Asynchronously creates or opens a dataset. Dataset should be explicitly closed with `dataset.close()` method if opened in `"w"` mode to flush any changes. Otherwise, datasets are closed when (and if) node decides to garbage collect them. * If the last parameter is a callback, then this callback is called on completion and undefined is returned. Otherwise the function returns a Promise resolved with the result. * * @example * ``` * var dataset = await gdal.openAsync('./data.shp');``` * * @example * ``` * var dataset = await gdal.openAsync(await fd.readFile('./data.shp'));``` * * @example * ``` * gdal.openAsync('./data.shp', (err, ds) => {...});``` * * @for gdal * @method openAsync * @static * @param {string|Buffer} path Path to dataset or in-memory Buffer to open * @param {string} [mode="r"] The mode to use to open the file: `"r"`, `"r+"`, or `"w"` * @param {string|string[]} [drivers] Driver name, or list of driver names to attempt to use. * * @param {number} [x_size] Used when creating a raster dataset with the `"w"` mode. * @param {number} [y_size] Used when creating a raster dataset with the `"w"` mode. * @param {number} [band_count] Used when creating a raster dataset with the `"w"` mode. * @param {string} [data_type] Used when creating a raster dataset with the `"w"` mode. * @param {string[]|object} [creation_options] Used when creating a dataset with the `"w"` mode. * @param {callback<Dataset>} [callback=undefined] {{{cb}}} * @return {Promise<Dataset>} */ export function openAsync(path: string|Buffer, mode?: string, drivers?: string|string[], x_size?: number, y_size?: number, band_count?: number, data_type?: string, creation_options?: string[]|object, callback?: callback<Dataset>): Promise<Dataset> /** * Creates vector polygons for all connected regions of pixels in the raster * sharing a common pixel value. Each polygon is created with an attribute * indicating the pixel value of that polygon. A raster mask may also be * provided to determine which pixels are eligible for processing. * * @throws Error * @method polygonize * @static * @for gdal * @param {PolygonizeOptions} options * @param {gdal.RasterBand} options.src * @param {gdal.Layer} options.dst * @param {gdal.RasterBand} [options.mask] * @param {number} options.pixValField The attribute field index indicating the feature attribute into which the pixel value of the polygon should be written. * @param {number} [options.connectedness=4] Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are. * @param {boolean} [options.useFloats=false] Use floating point buffers instead of int buffers. * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} */ export function polygonize(options: PolygonizeOptions): void /** * Creates vector polygons for all connected regions of pixels in the raster * sharing a common pixel value. Each polygon is created with an attribute * indicating the pixel value of that polygon. A raster mask may also be * provided to determine which pixels are eligible for processing. * {{{async}}} * * @throws Error * @method polygonizeAsync * @static * @for gdal * @param {PolygonizeOptions} options * @param {gdal.RasterBand} options.src * @param {gdal.Layer} options.dst * @param {gdal.RasterBand} [options.mask] * @param {number} options.pixValField The attribute field index indicating the feature attribute into which the pixel value of the polygon should be written. * @param {number} [options.connectedness=4] Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are. * @param {boolean} [options.useFloats=false] Use floating point buffers instead of int buffers. * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @param {callback<void>} [callback=undefined] {{{cb}}} * @return {Promise<void>} */ export function polygonizeAsync(options: PolygonizeOptions, callback?: callback<void>): Promise<void> /** * Disables all output. * * @for gdal * @static * @method quiet */ export function quiet(): void /** * Reprojects a dataset. * * @throws Error * @method reprojectImage * @static * @for gdal * @param {ReprojectOptions} options * @param {gdal.Dataset} options.src * @param {gdal.Dataset} options.dst * @param {gdal.SpatialReference} options.s_srs * @param {gdal.SpatialReference} options.t_srs * @param {string} [options.resampling] Resampling algorithm ({{#crossLink "Constants (GRA)"}}available options{{/crossLink}}) * @param {gdal.Geometry} [options.cutline] Must be in src dataset pixel coordinates. Use CoordinateTransformation to convert between georeferenced coordinates and pixel coordinates * @param {number[]} [options.srcBands] * @param {number[]} [options.dstBands] * @param {number} [options.srcAlphaBand] * @param {number} [options.dstAlphaBand] * @param {number} [options.srcNodata] * @param {number} [options.dstNodata] * @param {number} [options.memoryLimit] * @param {number} [options.maxError] * @param {boolean} [options.multi] * @param {string[]|object} [options.options] Warp options (see: [reference](https://gdal.org/doxygen/structGDALWarpOptions.html)) * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} */ export function reprojectImage(options: ReprojectOptions): void /** * Reprojects a dataset. * {{{async}}} * * @throws Error * @method reprojectImageAsync * @static * @for gdal * @param {ReprojectOptions} options * @param {gdal.Dataset} options.src * @param {gdal.Dataset} options.dst * @param {gdal.SpatialReference} options.s_srs * @param {gdal.SpatialReference} options.t_srs * @param {string} [options.resampling] Resampling algorithm ({{#crossLink "Constants (GRA)"}}available options{{/crossLink}}) * @param {gdal.Geometry} [options.cutline] Must be in src dataset pixel coordinates. Use CoordinateTransformation to convert between georeferenced coordinates and pixel coordinates * @param {number[]} [options.srcBands] * @param {number[]} [options.dstBands] * @param {number} [options.srcAlphaBand] * @param {number} [options.dstAlphaBand] * @param {number} [options.srcNodata] * @param {number} [options.dstNodata] * @param {number} [options.memoryLimit] * @param {number} [options.maxError] * @param {boolean} [options.multi] * @param {string[]|object} [options.options] Warp options (see:[reference](https://gdal.org/doxygen/structGDALWarpOptions.html) * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @param {callback<void>} [callback=undefined] {{{cb}}} * @return {Promise<void>} */ export function reprojectImageAsync(options: ReprojectOptions, callback?: callback<void>): Promise<void> /** * Set paths where proj will search it data. * * @for gdal * @static * @method setPROJSearchPaths * @param {string} Path `c:\ProjData` */ export function setPROJSearchPaths(Path: string): void /** * Removes small raster polygons. * * @throws Error * @method sieveFilter * @static * @for gdal * @param {SieveOptions} options * @param {gdal.RasterBand} options.src * @param {gdal.RasterBand} options.dst Output raster band. It may be the same as src band to update the source in place. * @param {gdal.RasterBand} [options.mask] All pixels in the mask band with a value other than zero will be considered suitable for inclusion in polygons. * @param {number} options.threshold Raster polygons with sizes smaller than this will be merged into their largest neighbour. * @param {number} [options.connectedness=4] Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are. * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} */ export function sieveFilter(options: SieveOptions): void /** * Removes small raster polygons. * {{{async}}} * * @throws Error * @method sieveFilterAsync * @static * @for gdal * @param {SieveOptions} options * @param {gdal.RasterBand} options.src * @param {gdal.RasterBand} options.dst Output raster band. It may be the same as src band to update the source in place. * @param {gdal.RasterBand} [options.mask] All pixels in the mask band with a value other than zero will be considered suitable for inclusion in polygons. * @param {number} options.threshold Raster polygons with sizes smaller than this will be merged into their largest neighbour. * @param {number} [options.connectedness=4] Either 4 indicating that diagonal pixels are not considered directly adjacent for polygon membership purposes or 8 indicating they are. * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @param {callback<void>} [callback=undefined] {{{cb}}} * @return {Promise<void>} */ export function sieveFilterAsync(options: SieveOptions, callback?: callback<void>): Promise<void> /** * Used to determine the bounds and resolution of the output virtual file which * should be large enough to include all the input image. * * @throws Error * @method suggestedWarpOutput * @static * @for gdal * @param {WarpOptions} options Warp options * @param {gdal.Dataset} options.src * @param {gdal.SpatialReference} options.s_srs * @param {gdal.SpatialReference} options.t_srs * @param {number} [options.maxError=0] * @return {WarpOutput} An object containing `"rasterSize"` and `"geoTransform"` * properties. */ export function suggestedWarpOutput(options: WarpOptions): WarpOutput /** * Used to determine the bounds and resolution of the output virtual file which * should be large enough to include all the input image. * {{{async}}} * * @throws Error * @method suggestedWarpOutputAsync * @static * @for gdal * @param {WarpOptions} options Warp options * @param {gdal.Dataset} options.src * @param {gdal.SpatialReference} options.s_srs * @param {gdal.SpatialReference} options.t_srs * @param {number} [options.maxError=0] * @param {callback<WarpOutput>} [callback=undefined] {{{cb}}} * @return {Promise<WarpOutput>} */ export function suggestedWarpOutputAsync(options: WarpOptions, callback?: callback<WarpOutput>): Promise<WarpOutput> /** * Returns a GDAL data type from a TypedArray (https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView#Typed_array_subclasses) * * @example * ``` * const dataType = gdal.fromDataType(array) * ```` * * @for gdal * @method toDataType * @throws TypeError * @param {TypedArray} array * @return {string} */ export function toDataType(array: TypedArray): string /** * Library version of gdal_translate * * @example * const ds = gdal.open('input.tif') * const out = gdal.translate('/vsimem/temp.tif', ds, [ '-b', '1' ]) * * @throws Error * @method translate * @for gdal * @static * @param {string} destination destination filename * @param {gdal.Dataset} source source dataset * @param {string[]} [args] array of CLI options for gdal_translate * @param {UtilOptions} [options] additional options * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @return {gdal.Dataset} */ export function translate(destination: string, source: Dataset, args?: string[], options?: UtilOptions): Dataset /** * Library version of gdal_translate * {{{async}}} * * @example * const ds = gdal.open('input.tif') * const out = gdal.translate('/vsimem/temp.tif', ds, [ '-b', '1' ]) * @throws Error * * @method translateAsync * @for gdal * @static * @param {string} destination destination filename * @param {gdal.Dataset} source source dataset * @param {string[]} [args] array of CLI options for gdal_translate * @param {UtilOptions} [options] additional options * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @param {callback<gdal.Dataset>} [callback=undefined] {{{cb}}} * @return {Promise<gdal.Dataset>} */ export function translateAsync(destination: string, source: Dataset, args?: string[], options?: UtilOptions, callback?: callback<Dataset>): Promise<Dataset> /** * Library version of ogr2ogr * * @example * const ds = gdal.open('input.geojson') * const out = gdal.vectorTranslate('/vsimem/temp.gpkg', [ '-of', 'GPKG' ], ds) * * @throws Error * @method vectorTranslate * @for gdal * @static * @param {string|gdal.Dataset} destination destination * @param {gdal.Dataset} source source dataset * @param {string[]} [args] array of CLI options for ogr2ogr * @param {UtilOptions} [options] additional options * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @return {gdal.Dataset} */ export function vectorTranslate(destination: string|Dataset, source: Dataset, args?: string[], options?: UtilOptions): Dataset /** * Library version of ogr2ogr * {{{async}}} * * @example * const ds = gdal.open('input.geojson') * const out = gdal.vectorTranslate('/vsimem/temp.gpkg', [ '-of', 'GPKG' ], ds) * @throws Error * * @method vectorTranslateAsync * @for gdal * @static * @param {string|gdal.Dataset} destination destination * @param {gdal.Dataset} source source dataset * @param {string[]} [args] array of CLI options for ogr2ogr * @param {UtilOptions} [options] additional options * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @param {callback<gdal.Dataset>} [callback=undefined] {{{cb}}} * @return {Promise<gdal.Dataset>} */ export function vectorTranslateAsync(destination: string|Dataset, source: Dataset, args?: string[], options?: UtilOptions, callback?: callback<Dataset>): Promise<Dataset> /** * Displays extra debugging information from GDAL. * * @for gdal * @static * @method verbose */ export function verbose(): void /** * Library version of gdalwarp * * @example * const ds = gdal.open('input.tif') * const output = gdal.warp('/vsimem/output.tiff', null, [ ds ], [ '-t_srs', 'epsg:3587' ]) * * @throws Error * @method warp * @for gdal * @static * @param {string|null} dst_path destination path, null for an in-memory operation * @param {gdal.Dataset|null} dst_ds destination dataset, null for a new dataset * @param {gdal.Dataset[]} src_ds array of source datasets * @param {string[]} [args] array of CLI options for gdalwarp * @param {UtilOptions} [options] additional options * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @return {gdal.Dataset} */ export function warp(dst_path: string|null, dst_ds: Dataset|null, src_ds: Dataset[], args?: string[], options?: UtilOptions): Dataset /** * Library version of gdalwarp * {{{async}}} * * @example * const ds = await gdal.openAsync('input.tif') * const output = await gdal.warpAsync('/vsimem/output.tiff', null, [ ds ], [ '-t_srs', 'epsg:3587' ]) * @throws Error * * @method warpAsync * @for gdal * @static * @param {string|null} dst_path destination path, null for an in-memory operation * @param {gdal.Dataset|null} dst_ds destination dataset, null for a new dataset * @param {gdal.Dataset[]} src_ds array of source datasets * @param {string[]} [args] array of CLI options for gdalwarp * @param {UtilOptions} [options] additional options * @param {ProgressCb} [options.progress_cb] {{{progress_cb}}} * @param {callback<gdal.Dataset>} [callback=undefined] {{{cb}}} * @return {Promise<gdal.Dataset>} */ export function warpAsync(dst_path: string|null, dst_ds: Dataset|null, src_ds: Dataset[], args?: string[], options?: UtilOptions, callback?: callback<Dataset>): Promise<Dataset> export class ArrayAttributes implements Iterable<Attrib