Skip to content

Commit 04d53c3

Browse files
authored
Merge pull request #13420 from rouault/gdal_mdim_convert_fix
gdal mdim convert: fix specifying multiple values for --group, --subset, --scale-axes
2 parents e014132 + a883381 commit 04d53c3

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

apps/gdalalg_mdim_convert.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,18 @@ GDALMdimConvertAlgorithm::GDALMdimConvertAlgorithm()
106106
AddArg("group", 0,
107107
_("Select a single group instead of converting the whole dataset."),
108108
&m_groups)
109-
.SetMetaVar("<GROUP-SPEC>");
109+
.SetMetaVar("<GROUP-SPEC>")
110+
.SetPackedValuesAllowed(false);
110111

111112
AddArg("subset", 0, _("Select a subset of the data."), &m_subsets)
112-
.SetMetaVar("<SUBSET-SPEC>");
113+
.SetMetaVar("<SUBSET-SPEC>")
114+
.SetPackedValuesAllowed(false);
113115

114116
AddArg("scale-axes", 0,
115117
_("Applies a integral scale factor to one or several dimensions"),
116118
&m_scaleAxes)
117-
.SetMetaVar("<SCALEAXES-SPEC>");
119+
.SetMetaVar("<SCALEAXES-SPEC>")
120+
.SetPackedValuesAllowed(false);
118121

119122
AddArg("strict", 0, _("Turn warnings into failures."), &m_strict);
120123
}

doc/source/programs/gdal_mdim_convert.rst

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Standard options
9797
<group_spec> may be just a group name, potentially using a fully qualified
9898
syntax (/group/subgroup/subsubgroup_name). Or it can be a combination of options
9999
with the syntax:
100-
name={src_group_name}[,dstname={dst_group_name}][,recursive=no]
100+
``name={src_group_name}[,dstname={dst_group_name}][,recursive=no]``
101101

102102
.. option:: --subset <subset_spec>
103103

@@ -107,15 +107,19 @@ Standard options
107107
<subset_spec> follows exactly the `OGC WCS 2.0 KVP encoding <https://portal.opengeospatial.org/files/09-147r3>`__
108108
for subsetting.
109109

110-
That is dim_name(min_val,max_val) or dim_name(sliced_val)
111-
The first syntax will subset the dimension dim_name to values in the
110+
That is ``dim_name(min_val,max_val)`` or ``dim_name(sliced_val)``
111+
The first syntax will subset the dimension ``dim_name`` to values in the
112112
[min_val,max_val] range. The second syntax will slice the dimension dim_name
113113
to value sliced_val (and this dimension will be removed from the arrays
114114
that reference to it)
115115

116+
Beware that dimension name is case sensitive.
117+
118+
Several subsetting operations along different dimensions can be specified by repeating the option.
119+
116120
Using --subset is incompatible with specifying a *view* option in --array.
117121

118-
See :example:`mdim-convert-subset-1`.
122+
See :example:`mdim-convert-subset-1` or :example:`mdim-convert-subset-2`.
119123

120124
.. option:: --scale-axes <scaleaxes_spec>
121125

@@ -127,9 +131,11 @@ Standard options
127131
`OGC WCS 2.0 Scaling Extension <https://portal.opengeospatial.org/files/12-039>`__,
128132
but limited to integer scale factors.
129133

130-
That is <dim1_name>(<scale_factor>)[,<dim2_name>(<scale_factor>)]...
134+
That is ``<dim1_name>(<scale_factor>)``.
131135

132-
Using --scaleaxes is incompatible with specifying a *view* option in --array.
136+
Several scaling operations along different dimensions can be specified by repeating the option.
137+
138+
Using --scale-axes is incompatible with specifying a *view* option in --array.
133139

134140
See :example:`mdim-convert-subsample-1`.
135141

@@ -165,12 +171,20 @@ Examples
165171
gdal mdim convert in.nc out.tif --subset "time(\"2010-01-01\")" --array temperature
166172
167173
.. example::
168-
:title: Subsample along X and Y axis
174+
:title: Extract a a 3D chunk from a time-indexed GRIB file into a multiband GeoTIFF.
175+
:id: mdim-convert-subset-2
176+
177+
.. code-block:: bash
178+
179+
gdal mdim convert /vsicurl/https://tgftp.nws.noaa.gov/SL.us008001/ST.opnl/DF.gr2/DC.ndfd/AR.conus/VP.001-003/ds.qpf.bin tst.tif --subset "TIME(1763164800,1763251200)" --array QPF_0-SFC --co COMPRESS=DEFLATE
180+
181+
.. example::
182+
:title: Subsample along x and y axis
169183
:id: mdim-convert-subsample-1
170184

171185
.. code-block:: bash
172186
173-
gdal mdim convert in.nc out.nc --scaleaxes "X(2),Y(2)"
187+
gdal mdim convert in.nc out.nc --scale-axes "x(2),y(2)"
174188
175189
.. example::
176190
:title: Reorder the values of an array

0 commit comments

Comments
 (0)