API · C++ CLASSES · Dataset

Dataset

Returned by Gdal.openEx and the operations. The per-dataset programs and accessors. Always close() when done. Operation options are GDAL CLI flags via Module.toVector("VectorString", […]).

Usage

inspect, then translate
const ds = await Gdal.openEx("/opfs/dem.tif");
console.log(await ds.getRasterXSize(), await ds.getProjectionRef());

const opts = await Module.toVector("VectorString", ["-of", "COG"]);
const cog = await ds.translate("/opfs/dem-cog.tif", opts);
await cog.close();
await ds.close();

Operations

METHOD DESCRIPTION
translate(dest, opts) Raster convert / subset / reformat (gdal_translate) → Dataset.
vectorTranslate(dest, opts) · vectorTranslate2(dstDS, opts) Vector convert / reproject (ogr2ogr); the 2 form writes into an existing dataset.
rasterize(dest, opts) · rasterize(dstDS, opts) Burn vectors into a raster (gdal_rasterize); two overloads.
demProcessing(dest, processing, colorFile, opts) DEM derivatives (gdaldem): "hillshade", "slope", "aspect", "color-relief", …
nearblack(dest, dstDS, opts) · grid(dest, opts) · footprint(dest, dstDS, opts) Collar removal, point gridding, and footprint extraction.

Info

METHOD DESCRIPTION
info(opts) · vectorInfo(opts) · multiDimInfo(opts)string Metadata as text; pass ["-json"] and JSON.parse the result.

Raster

METHOD DESCRIPTION
getRasterXSize() · getRasterYSize() · getRasterCount() Raster dimensions and band count.
buildOverviews(resampling, levels, opts) · addBand(type, opts) · createMaskBand(flags) Build pyramids; add a band; add a mask band.
flushCache() · clearStatistics() Flush pending writes; drop cached band statistics.

Georeferencing

METHOD DESCRIPTION
getGeoTransform()double[] · setGeoTransform(gt) The affine pixel-to-world transform.
getProjectionRef() · setProjection(wkt) The coordinate system as WKT.
getGCPs()GCP[] · setGCPs(gcps, projection) · getGCPCount() · getGCPProjection() Ground-control points (see GCP).

Vector / layers

METHOD DESCRIPTION
getLayerCount() · deleteLayer(i) · isLayerPrivate(i) · resetReading() · testCapability(cap) Layer count, deletion, capability probing.
startTransaction(force) · commitTransaction() · rollbackTransaction() · abortSQL() Transactions on writable vector datasets.
getFieldDomainNames(opts) · deleteFieldDomain(name) · getRelationshipNames(opts) · deleteRelationship(name) Field domains and relationships.

Note: per-band, per-layer and per-feature read APIs (getRasterBand, getLayer, readRaster, executeSQL, …) are not exposed in v3. Work at the program level (translate, info with -json) instead.

Lifecycle

METHOD DESCRIPTION
close() Release the dataset. Required, especially in worker mode.
getDriver()Driver · getFileList()string[] The owning driver; every file the dataset produced (multi-file outputs like Shapefile).