Skip to content

Commit

Permalink
VRT a_nodata for vrt:// connection
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Nov 24, 2023
1 parent fe649a8 commit 66f4425
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions autotest/gcore/vrt_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,9 @@ def test_vrt_protocol():
1e-9,
)

ds = gdal.Open("vrt://data/float32.tif?a_nodata=-9999")
assert ds.GetRasterBand(1).GetNoDataValue() == -9999.0

## multiple open options
ds = gdal.Open(
"vrt://data/byte_with_ovr.tif?oo=GEOREF_SOURCES=TABFILE,OVERVIEW_LEVEL=0"
Expand Down
5 changes: 4 additions & 1 deletion doc/source/drivers/raster/vrt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,7 @@ For example:
vrt://my.tif?bands=2&ovr=4


The supported options currently are ``bands``, ``a_srs``, ``a_ullr``, ``ovr``, ``expand``,
The supported options currently are ``bands``, ``a_nodata``, ``a_srs``, ``a_ullr``, ``ovr``, ``expand``,
``a_scale``, ``a_offset``, ``ot``, ``gcp``, ``if``, ``scale``, ``exponent``, ``outsize``, ``projwin``,
``projwin_srs``, ``tr``, ``r``, ``srcwin``, ``a_gt``, ``oo``, ``unscale``, ``a_coord_epoch``, ``nogcp``, ``epo``, and ``eco``.

Expand All @@ -1914,6 +1914,9 @@ are the source band numbers (between 1 and N), possibly out-of-order or with rep
The ``mask`` value can be used to specify the global mask band. This can also
be seen as an equivalent of running `gdal_translate -of VRT -b num1 ... -b numN`.

The effect of the ``a_nodata`` option (added in GDAL 3.9) is to assign (override) the nodata
value of the source in the same way as (:ref:`gdal_translate`).

The effect of the ``a_srs`` option (added in GDAL 3.7) is to assign (override) the coordinate
reference system of the source in the same way as (:ref:`gdal_translate`), it may be missing,
or incorrect. The value provided for ``a_srs`` may be a string or a file containing a srs
Expand Down
6 changes: 6 additions & 0 deletions frmts/vrt/vrtdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,12 @@ GDALDataset *VRTDataset::OpenVRTProtocol(const char *pszSpec)
}
}

else if (EQUAL(pszKey, "a_nodata"))
{
argv.AddString("-a_nodata");
argv.AddString(pszValue);
}

else if (EQUAL(pszKey, "a_srs"))
{
argv.AddString("-a_srs");
Expand Down

0 comments on commit 66f4425

Please sign in to comment.