GDAL Knowledge Patch
Use this skill when changing GDAL applications, bindings, out-of-tree drivers,
builds, command lines, pipelines, or data-access configuration. Inspect the
project's manifest and linked GDAL at runtime before applying version-sensitive
advice. Prefer the project's headers, generated API documentation, tests, and
observed driver metadata when they disagree with assumptions.
Reference index
| Reference |
Topics |
| Bindings, Build, and Packaging |
Dependency compatibility, CMake, installed headers, Python, Java, C#, and SWIG |
| CLI and Pipelines |
Unified commands, pipeline composition, utility options, output, and failure semantics |
| Migrations and Core API |
C/C++ source migrations, ABI changes, CPL, dataset, geometry, CRS, and algorithm APIs |
| Multidimensional Data and Georeferencing |
Multidimensional arrays, HDF, netCDF, transforms, geolocation, and slicing |
| Raster Formats |
GeoTIFF/COG, imagery, scientific, hydrographic, and tiled raster drivers |
| Raster Processing |
Warp, resampling, nodata, VRT, overviews, statistics, contours, and pansharpening |
| Vector Formats and Databases |
OGR formats, SQL databases, Arrow/Parquet, schemas, services, and vector geometry |
| Virtual Filesystems and Cloud |
VSI paths, cloud authentication, HTTP, caching, redirects, sync, and archives |
Upgrade checks first
Update out-of-tree driver signatures
For the 3.11 API transition:
- Include
gcore/gdal_fwd.h instead of redeclaring public opaque types.
- Override protected
IGetExtent()/IGetExtent3D() hooks rather than the
checked public extent methods.
- Override
ISetSpatialFilter() and return/check OGRErr from spatial-filter
calls.
- Handle
GDT_Float16 and GDT_CFloat16; request GDT_Float32 conversion
when native half precision is unsuitable.
- Treat partial coordinate-transform failure as aggregate failure and inspect
the per-point success or error-code arrays.
For the 3.12 API transition:
- Make dataset and layer inspection overrides const-correct and store returned
layer definitions and spatial references through const pointers.
- Handle
GFT_Boolean, GFT_DateTime, and GFT_WKBGeometry; check the
CPLErr returned by raster-attribute-table mutation.
- Change geotransform overrides from six-double pointers to
GDALGeoTransform references.
- Do not assume raw-file VRT bands have unrestricted access; honor the runtime
policy and the build-time raw-band gate.
For the 3.13 API transition:
- Check
OGRErr from C point-setting and point-adding functions.
- Replace
MIN, MAX, and ABS from GDAL headers with CPL_MIN, CPL_MAX,
and CPL_ABS; arrange your own M_PI declaration.
- Update
GDALDataset::Close() overrides for progress arguments and option
lists to CSLConstList where required.
- Treat metadata lists as const and update custom VSI
Read()/Write()
overrides to the single-count form.
- Account for RasterIO resampling operating in the output buffer type unless
bOperateInBufType is false.
Audit removals, restorations, and binary compatibility
The 3.11 line removed many legacy raster and vector drivers, several writers,
the OpenCL warper, and unofficial utilities. It also redirected FileGDB writes
to OpenFileGDB, deprecated OGR Memory in favor of MEM, removed PDF
GEO_ENCODING=OGC_BP, and bumped the shared-library major version. GSBG,
GSAG, and BT were restored in later 3.11 maintenance releases; Tiger and UK
.NTF returned later as future-removal candidates. Never infer availability from
the initial removal list alone. Rebuild binary dependents whenever the shared
library major changes.
Migrate unified command paths
The unified gdal front end covers raster, vector, multidimensional, dataset,
driver, and VSI work. In 3.12, several gdal vector geom ... operations moved
directly beneath gdal vector, and geom set-type became set-geom-type.
Update scripts to the direct paths. CLI info commands default to text while API
calls retain JSON defaults, and progress goes to standard output unless quiet.
The 3.13 command argument spelling favors --input and --output; older
--src/--dst aliases remain accepted. Avoid parsing incidental standard
output from tiling pipelines, and request JSON explicitly when automation
depends on it.
Treat failure status as part of the API
- Check algorithm argument validation, cancellation, close-time progress,
field-domain operations, raster-attribute mutations, and geometry mutations.
ogr2ogr now fails by default when destination field creation fails; use
-skip only when dropping fields is intentional.
ogr2ogr also returns a nonzero status for VRT-processing errors.
INIT_DEST=NO_DATA without a nodata value warns and zero-fills in 3.11.5,
but fails in 3.13.0. Gate behavior when supporting both.
- GTI reads fail when a source is unreadable, missing Kerchunk and ADBC targets
are errors, and contouring an all-nodata raster succeeds with empty output.
High-value current workflows
Compose algorithms and pipelines
Use the algorithm registry rather than shelling out when an in-process API is
needed. Python exposes dynamically generated gdal.alg.*() calls and accepts a
progress callback. Pipelines can mix raster and vector stages, nest other
pipelines, branch with tee, invoke external, override saved parameters, and
use _ to select a non-first dataset emitted by a preceding stage.
Materialize intermediate data when a following stage requires a concrete
dataset. Named outputs infer their format, while an anonymous COG can flow
directly into tile. Keep filters before gdal vector limit; current behavior
applies the filtered stream.
Use raster algebra and VRT expressions
Raster bands support arithmetic, comparisons, AsType(), common math and
aggregation functions, and IfThenElse(). VRT derived bands provide richer
aggregates, expressions, reclassification, constants, coordinate variables,
transpose and block controls. Ensure muparser is present for C++ VRT
expressions; exprtk is optional and increases library size.
For calculations, choose --dialect=muparser|builtin deliberately, account for
nodata, and use --flatten where required. The built-in dialect can reduce all
bands of one input to one output band. Inputs without geotransforms and nested
pipeline inputs are supported.
Select correct warp and resampling semantics
Check per-point transform results, output-buffer data type, exact integer
nodata comparisons, and NaN nodata handling. Lanczos no longer has its old
half-valid-pixel threshold, RMS overview normalization changed, and sum
resampling no longer carries the earlier chunking artifacts. Use
TransformBounds() semantics for -te with -te_srs.
When --target-aligned-pixels is used for a raster mosaic, also provide
--resolution. Reprojection can use all CPUs by default, so set thread counts
explicitly when resource limits matter. For global or TPS warps, retain the
corrected longitude and SOURCE_EXTRA=5 behavior.
Handle modern raster types and COG creation
Treat GDT_UInt8 as the canonical unsigned eight-bit type; GDT_Byte is an
alias. Support Float16/CFloat16 in dispatch, prediction, statistics, and nodata
paths. COG supports band/tile interleave, complex data, random-write creation,
and BigTIFF temporary files; multiband overview creation works through its
multithreaded path.
When translating a selected mask to COG, the mask becomes a regular alpha-tagged
band. Creation options for lossy JPEG XL require JXL_LOSSLESS=NO; otherwise
GTiff and COG warn. Do not assume a structurally valid COG needs GDAL's ghost
area for LAYOUT=COG reporting.
Work safely with cloud and curl-backed paths
Authentication changes invalidate relevant cloud caches. Keep redirect
authorization scoped, especially for S3-like redirects, and use path-specific
controls for query strings, headers, connection limits, cache behavior, and
verbatim path handling. /vsis3/ supports IAM Identity Center,
credential_process, directory buckets, and endpoint URLs with schemes.
Use permitted header_file names, expect /vsicurl/ to fall back to a bounded
GET when size is absent from HEAD, and remember that multithreaded cloud sync
includes empty files. For Azure/ADLS, token and SAS settings are exposed in
handler option metadata.
Preserve vector schemas and geometry fidelity
Unified vector algorithms propagate field domains, relationships, and metadata.
Conversion warns when curves, Z, or M cannot be preserved. Parquet supports
editable layers, geometry logical types, list variants, Timestamp With Offset,
Hive filtering, covering bounding boxes, partition metadata, and ignored-field
name collisions.
Expect geometry-producing operations to return richer types: edge-built
polygons may be multipolygons, polar reprojection closes polygon rings, and
GeoJSON export has explicit curve, measure, and coordinate-order controls.
PostGIS can use full-geometry intersection; select local or server-side spatial
filtering deliberately.
Verification checklist
Before shipping a change:
- Confirm the loaded GDAL version and shared-library ABI.
- Query driver metadata for create, update, append, upsert, subdataset,
reopen, close-visibility, and directory-oriented capabilities.
- Exercise failure paths, progress interruption, and explicit
Close() for
buffered Arrow/Parquet or other long-running output.
- Test representative nodata, mask, alpha, Float16, complex, and very large
raster cases.
- Test CRS axis mapping, partial failures, polar/global bounds, and
geotransform consistency.
- Run command automation with explicit output format and inspect exit status.
- Test cloud paths with the intended credentials, redirects, cache policy,
empty objects, and path normalization.
- For bindings, test ownership, repeated closure, no-GIL execution where
applicable, NumPy dtypes/strides, and option-list parsing.
1---2name: gdal-knowledge-patch3description: GDAL4license: MIT5---678# GDAL Knowledge Patch910Use this skill when changing GDAL applications, bindings, out-of-tree drivers,11builds, command lines, pipelines, or data-access configuration. Inspect the12project's manifest and linked GDAL at runtime before applying version-sensitive13advice. Prefer the project's headers, generated API documentation, tests, and14observed driver metadata when they disagree with assumptions.1516## Reference index1718| Reference | Topics |19| --- | --- |20| [Bindings, Build, and Packaging](references/bindings-build-and-packaging.md) | Dependency compatibility, CMake, installed headers, Python, Java, C#, and SWIG |21| [CLI and Pipelines](references/cli-and-pipelines.md) | Unified commands, pipeline composition, utility options, output, and failure semantics |22| [Migrations and Core API](references/migrations-and-core-api.md) | C/C++ source migrations, ABI changes, CPL, dataset, geometry, CRS, and algorithm APIs |23| [Multidimensional Data and Georeferencing](references/multidimensional-and-georeferencing.md) | Multidimensional arrays, HDF, netCDF, transforms, geolocation, and slicing |24| [Raster Formats](references/raster-formats.md) | GeoTIFF/COG, imagery, scientific, hydrographic, and tiled raster drivers |25| [Raster Processing](references/raster-processing.md) | Warp, resampling, nodata, VRT, overviews, statistics, contours, and pansharpening |26| [Vector Formats and Databases](references/vector-formats-and-databases.md) | OGR formats, SQL databases, Arrow/Parquet, schemas, services, and vector geometry |27| [Virtual Filesystems and Cloud](references/virtual-filesystems-and-cloud.md) | VSI paths, cloud authentication, HTTP, caching, redirects, sync, and archives |2829## Upgrade checks first3031### Update out-of-tree driver signatures3233For the 3.11 API transition:3435- Include `gcore/gdal_fwd.h` instead of redeclaring public opaque types.36- Override protected `IGetExtent()`/`IGetExtent3D()` hooks rather than the37 checked public extent methods.38- Override `ISetSpatialFilter()` and return/check `OGRErr` from spatial-filter39 calls.40- Handle `GDT_Float16` and `GDT_CFloat16`; request `GDT_Float32` conversion41 when native half precision is unsuitable.42- Treat partial coordinate-transform failure as aggregate failure and inspect43 the per-point success or error-code arrays.4445For the 3.12 API transition:4647- Make dataset and layer inspection overrides const-correct and store returned48 layer definitions and spatial references through const pointers.49- Handle `GFT_Boolean`, `GFT_DateTime`, and `GFT_WKBGeometry`; check the50 `CPLErr` returned by raster-attribute-table mutation.51- Change geotransform overrides from six-double pointers to52 `GDALGeoTransform` references.53- Do not assume raw-file VRT bands have unrestricted access; honor the runtime54 policy and the build-time raw-band gate.5556For the 3.13 API transition:5758- Check `OGRErr` from C point-setting and point-adding functions.59- Replace `MIN`, `MAX`, and `ABS` from GDAL headers with `CPL_MIN`, `CPL_MAX`,60 and `CPL_ABS`; arrange your own `M_PI` declaration.61- Update `GDALDataset::Close()` overrides for progress arguments and option62 lists to `CSLConstList` where required.63- Treat metadata lists as const and update custom VSI `Read()`/`Write()`64 overrides to the single-count form.65- Account for RasterIO resampling operating in the output buffer type unless66 `bOperateInBufType` is false.6768### Audit removals, restorations, and binary compatibility6970The 3.11 line removed many legacy raster and vector drivers, several writers,71the OpenCL warper, and unofficial utilities. It also redirected FileGDB writes72to OpenFileGDB, deprecated OGR `Memory` in favor of `MEM`, removed PDF73`GEO_ENCODING=OGC_BP`, and bumped the shared-library major version. GSBG,74GSAG, and BT were restored in later 3.11 maintenance releases; Tiger and UK75.NTF returned later as future-removal candidates. Never infer availability from76the initial removal list alone. Rebuild binary dependents whenever the shared77library major changes.7879### Migrate unified command paths8081The unified `gdal` front end covers raster, vector, multidimensional, dataset,82driver, and VSI work. In 3.12, several `gdal vector geom ...` operations moved83directly beneath `gdal vector`, and `geom set-type` became `set-geom-type`.84Update scripts to the direct paths. CLI info commands default to text while API85calls retain JSON defaults, and progress goes to standard output unless quiet.8687The 3.13 command argument spelling favors `--input` and `--output`; older88`--src`/`--dst` aliases remain accepted. Avoid parsing incidental standard89output from tiling pipelines, and request JSON explicitly when automation90depends on it.9192### Treat failure status as part of the API9394- Check algorithm argument validation, cancellation, close-time progress,95 field-domain operations, raster-attribute mutations, and geometry mutations.96- `ogr2ogr` now fails by default when destination field creation fails; use97 `-skip` only when dropping fields is intentional.98- `ogr2ogr` also returns a nonzero status for VRT-processing errors.99- `INIT_DEST=NO_DATA` without a nodata value warns and zero-fills in 3.11.5,100 but fails in 3.13.0. Gate behavior when supporting both.101- GTI reads fail when a source is unreadable, missing Kerchunk and ADBC targets102 are errors, and contouring an all-nodata raster succeeds with empty output.103104## High-value current workflows105106### Compose algorithms and pipelines107108Use the algorithm registry rather than shelling out when an in-process API is109needed. Python exposes dynamically generated `gdal.alg.*()` calls and accepts a110`progress` callback. Pipelines can mix raster and vector stages, nest other111pipelines, branch with `tee`, invoke `external`, override saved parameters, and112use `_` to select a non-first dataset emitted by a preceding stage.113114Materialize intermediate data when a following stage requires a concrete115dataset. Named outputs infer their format, while an anonymous COG can flow116directly into `tile`. Keep filters before `gdal vector limit`; current behavior117applies the filtered stream.118119### Use raster algebra and VRT expressions120121Raster bands support arithmetic, comparisons, `AsType()`, common math and122aggregation functions, and `IfThenElse()`. VRT derived bands provide richer123aggregates, expressions, reclassification, constants, coordinate variables,124transpose and block controls. Ensure muparser is present for C++ VRT125expressions; exprtk is optional and increases library size.126127For calculations, choose `--dialect=muparser|builtin` deliberately, account for128nodata, and use `--flatten` where required. The built-in dialect can reduce all129bands of one input to one output band. Inputs without geotransforms and nested130pipeline inputs are supported.131132### Select correct warp and resampling semantics133134Check per-point transform results, output-buffer data type, exact integer135nodata comparisons, and NaN nodata handling. Lanczos no longer has its old136half-valid-pixel threshold, RMS overview normalization changed, and sum137resampling no longer carries the earlier chunking artifacts. Use138`TransformBounds()` semantics for `-te` with `-te_srs`.139140When `--target-aligned-pixels` is used for a raster mosaic, also provide141`--resolution`. Reprojection can use all CPUs by default, so set thread counts142explicitly when resource limits matter. For global or TPS warps, retain the143corrected longitude and `SOURCE_EXTRA=5` behavior.144145### Handle modern raster types and COG creation146147Treat `GDT_UInt8` as the canonical unsigned eight-bit type; `GDT_Byte` is an148alias. Support Float16/CFloat16 in dispatch, prediction, statistics, and nodata149paths. COG supports band/tile interleave, complex data, random-write creation,150and BigTIFF temporary files; multiband overview creation works through its151multithreaded path.152153When translating a selected mask to COG, the mask becomes a regular alpha-tagged154band. Creation options for lossy JPEG XL require `JXL_LOSSLESS=NO`; otherwise155GTiff and COG warn. Do not assume a structurally valid COG needs GDAL's ghost156area for `LAYOUT=COG` reporting.157158### Work safely with cloud and curl-backed paths159160Authentication changes invalidate relevant cloud caches. Keep redirect161authorization scoped, especially for S3-like redirects, and use path-specific162controls for query strings, headers, connection limits, cache behavior, and163verbatim path handling. `/vsis3/` supports IAM Identity Center,164`credential_process`, directory buckets, and endpoint URLs with schemes.165166Use permitted `header_file` names, expect `/vsicurl/` to fall back to a bounded167GET when size is absent from HEAD, and remember that multithreaded cloud sync168includes empty files. For Azure/ADLS, token and SAS settings are exposed in169handler option metadata.170171### Preserve vector schemas and geometry fidelity172173Unified vector algorithms propagate field domains, relationships, and metadata.174Conversion warns when curves, Z, or M cannot be preserved. Parquet supports175editable layers, geometry logical types, list variants, Timestamp With Offset,176Hive filtering, covering bounding boxes, partition metadata, and ignored-field177name collisions.178179Expect geometry-producing operations to return richer types: edge-built180polygons may be multipolygons, polar reprojection closes polygon rings, and181GeoJSON export has explicit curve, measure, and coordinate-order controls.182PostGIS can use full-geometry intersection; select local or server-side spatial183filtering deliberately.184185## Verification checklist186187Before shipping a change:1881891. Confirm the loaded GDAL version and shared-library ABI.1902. Query driver metadata for create, update, append, upsert, subdataset,191 reopen, close-visibility, and directory-oriented capabilities.1923. Exercise failure paths, progress interruption, and explicit `Close()` for193 buffered Arrow/Parquet or other long-running output.1944. Test representative nodata, mask, alpha, Float16, complex, and very large195 raster cases.1965. Test CRS axis mapping, partial failures, polar/global bounds, and197 geotransform consistency.1986. Run command automation with explicit output format and inspect exit status.1997. Test cloud paths with the intended credentials, redirects, cache policy,200 empty objects, and path normalization.2018. For bindings, test ownership, repeated closure, no-GIL execution where202 applicable, NumPy dtypes/strides, and option-list parsing.