API · C++ CLASSES · Gdal
Gdal
The static entry point, imported as Gdal (also reachable as
Module.Gdal). Operation results are new Dataset objects;
remember to close() them. Operations take a string vector of plain GDAL CLI
flags via Module.toVector("VectorString", […]).
Usage
open, convert, close Copy
import { initCppJs , Gdal } from " gdal3.js/Gdal.h " ;
const Module = await initCppJs ({ useWorker : true });
await Gdal . allRegister ();
const ds = await Gdal . openEx ( " /opfs/cities.gpkg " );
if ( ! ds ) throw new Error ( await Gdal . getLastErrorMsg ());
const opts = await Module . toVector ( " VectorString " , [ " -f " , " GeoJSON " ]);
const out = await ds . vectorTranslate ( " /opfs/cities.geojson " , opts );
await out . close ();
await ds . close ();
Open & identify
METHOD
DESCRIPTION
openEx(path[, flags[, allowedDrivers, openOptions, siblingFiles]])
Open raster or vector → Dataset (null on failure). The form
the apps use; four overloads.
open(path[, eAccess])
GDALOpen: raster-oriented, returns null for vector inputs. Prefer
openEx.
openShared(path, eAccess)
Open with dataset sharing.
identifyDriver(path, fileList) ·
identifyDriverEx(path, flags, allowedDrivers, fileList)
Which driver would open this path → Driver (null if none).
Multi-dataset operations
These take source datasets as a VectorDataset; the per-dataset operations
live on Dataset .
METHOD
DESCRIPTION
warp(dest, dstDS, srcDSs, opts)
Reproject / mosaic (gdalwarp). Pass null for
dstDS; sources as toVector("VectorDataset", [src]).
buildVRT(dest, srcDSs, srcNames, opts)
Build a virtual mosaic (gdalbuildvrt) over several sources.
multiDimTranslate(dest, dstDS, srcDSs, opts)
Multidimensional translate (gdalmdimtranslate).
Drivers
METHOD
DESCRIPTION
getDrivers() → Driver[]
Every registered driver. Wrap with Module.toArray(...).
getDriverCount() · getDriver(i) ·
getDriverByName(name)
Count, by index, by short name (e.g. "GTiff").
allRegister()
Register the built-in driver set. Call once after boot.
registerPlugins() · registerPlugin(name) ·
destroyDriverManager()
Plugin registration and driver-manager teardown.
Config
METHOD
DESCRIPTION
setThreadLocalConfigOption(key, value) ·
getThreadLocalConfigOption(key, def)
Set / read a GDAL config option. Use these to set options.
getConfigOption(key, def) ·
getGlobalConfigOption(key, def) · getConfigOptions()
Read effective / global config; dump all.
setPathSpecificOption(prefix, key, value) ·
getPathSpecificOption(path, key, def) ·
clearPathSpecificOptions(prefix)
Per-path-prefix config (e.g. credentials for a VSI prefix).
setConfigOption(key, value)
Avoid: in this build it only sets GDAL_DATA and
ignores key. Use setThreadLocalConfigOption for real
config.
Errors
Full handling in the error-handling guide .
METHOD
DESCRIPTION
getLastErrorMsg() · getLastErrorNo() ·
getLastErrorType()
The last GDAL error message, code, and class.
errorReset() · getErrorCounter()
Clear the error state; how many errors so far.
error(eClass, errNo, msg) · popErrorHandler() ·
setCurrentErrorHandlerCatchDebug(flag)
Emit an error; pop a handler; toggle debug-message catching.
vsiGetLastErrorMsg() · vsiGetLastErrorNo() ·
vsiErrorReset()
The VSI (virtual filesystem) error channel.
Virtual filesystem
Manage files in the VFS (/opfs, /vsimem/, …). See the
VFS guide .
METHOD
DESCRIPTION
readDir(dir) · readDirRecursive(path)
List a directory, flat or recursive.
mkdir(dir, mode) · mkdirRecursive(path, mode) ·
rmdir(dir) · rmdirRecursive(dir)
Create / remove directories.
unlink(file) · unlinkBatch(files) ·
rename(old, new) · copyFile(new, old)
Delete, batch-delete, rename, copy files.
fileFromMemBuffer(name, bytes)
Create a /vsimem/ file from a byte array.
getFileSystemsPrefixes() · getFileSystemOptions(name) ·
getActualURL(name) · getSignedURL(name, opts)
VSI prefix introspection and URL resolution / signing.
Geo math
METHOD
DESCRIPTION
gcpsToGeoTransform(gcps, geoTransform, approxOK)
Fit a geotransform to ground-control points (see GCP ).
applyGeoTransform(gt, x, y) · invGeoTransform(gt)
Pixel ↔ world coordinates; invert a geotransform.
decToDMS(a, b, c) · packedDMSToDec(a) ·
decToPackedDMS(a)
Decimal degrees ↔ degrees-minutes-seconds.
Cache & data types
METHOD
DESCRIPTION
setCacheMax(bytes) · getCacheMax() ·
getCacheUsed()
The raster block cache (see memory ).
getDataTypeName(t) · getDataTypeByName(name) ·
getDataTypeSize(t) · dataTypeIsComplex(t) ·
dataTypeUnion(a, b)
GDAL pixel-type helpers.
getColorInterpretationName(i) ·
getPaletteInterpretationName(i)
Enum-to-name helpers.
Misc & advanced
METHOD
DESCRIPTION
versionInfo(request)
GDAL version strings, e.g. "RELEASE_NAME" → "3.13.1".
getNumCPUs() · getUsablePhysicalRAM()
Runtime capabilities.
getSubdatasetInfo(path) → SubdatasetInfo
Parse a subdataset path (see SubdatasetInfo ).
parseCommandLine(cmd) · escapeString(s, len, scheme) ·
binaryToHex(n, bytes) · hexToBinary(hex)
String / argument utilities.
setProjDataPath(path) · findFile(class, base) ·
pushFinderLocation(l) · popFinderLocation() ·
finderClean()
Supporting-data (PROJ, GDAL data) file resolution.
goa2GetAuthorizationURL(scope) ·
goa2GetRefreshToken(...) · goa2GetAccessToken(...)
Google OAuth2 token flow (for cloud drivers).