gdalmdimtranslate

3.1 新版功能.

在不同格式之间转换多维数据,并执行子设置。

简介

gdalmdimtranslate [--help-general] [-co "NAME=VALUE"]*
                  [-of format] [-array <array_spec>]*
                  [-group <group_spec>]*
                  [-subset <subset_spec>]*
                  [-scaleaxes <scaleaxes_spec>]*
                  [-oo NAME=VALUE]*
                  <src_filename> <dst_filename>

描述

gdalmdimtranslate 程序在不同格式之间转换多维栅格,和/或可以执行特定数组和组的选择性转换和/或子集操作。

以下命令行参数可以按任意顺序显示。

-of <format>

选择输出格式。这可以是一种支持多维输出的格式(例如 NetCDF:网络通用数据格式多维VRT ),或“经典”二维格式(如果只有一个二维数组是其他指定转换操作的结果)。如果未指定此选项,则尽可能从目标文件名的扩展名猜测格式。

-co <NAME=VALUE>

许多格式都有一个或多个可选的创建选项,可用于控制所创建文件的详细信息。

可用的创建选项因格式驱动程序而异,有些简单格式根本没有创建选项。格式支持的选项列表可以与 --formats 命令行选项,但该格式的文档是有关驱动程序创建选项的最终信息源。见 栅格驱动器 每种格式的法律创建选项的特定格式文档。

数组级创建选项可以通过在它们前面加前缀来传递 ARRAY: . 见 GDALGroup::CopyFrom() 有关此类选项的更多详细信息。

-array <array_spec>

与其转换整个数据集,不如选择一个数组,并可能对其执行操作。可以多次指定此选项以在不同阵列上操作。

<array_spec> may be just an array name, potentially using a fully qualified syntax (/group/subgroup/array_name). Or it can be a combination of options with the syntax: name={src_array_name}[,dstname={dst_array_name}][,transpose=[{axis1},{axis2},...][,view={view_expr}]

[{axis1},{axis2},...] is the argument of GDALMDArray::Transpose(). For example, transpose=[1,0] switches the axis order of a 2D array.

{view_expr} is the value of the viewExpr argument of GDALMDArray::GetView()

指定对维度执行切片或子集设置的视图表达式时,等效操作将应用于相应的索引变量。

-group <group_spec>

Instead of converting the whole dataset, select one group, and possibly perform operations on it. This option can be specified several times to operate on different groups. If only one group is specified, its content will be copied directly to the target root group. If several ones are specified, they are copied under the target root group

<group_spec> may be just a group name, potentially using a fully qualified syntax (/group/subgroup/subsubgroup_name). Or it can be a combination of options with the syntax: name={src_group_name}[,dstname={dst_group_name}][,recursive=no]

-subset <subset_spec>

执行沿维度的子集(修剪或切片)操作,前提是该维度由数字或字符串数据类型的1D变量索引,并且其值是单序排序的。<subset_spec>完全遵循 OGC WCS 2.0 KVP encoding 用于子集。

即dim_name(min_val,max_val)或dim_name(sliced_val)第一个语法将维度dim_name子集为 [min_val,max_val] 范围。第二个语法将把维度dim_name分割为值sliced_val(这个维度将从引用它的数组中删除)

使用-subset与指定 view 数组中的选项。

-scaleaxes <scaleaxes_spec>

对一个或多个维度应用积分比例因子,即每N个值提取1个值(不重新采样)。

<scaleaxes_spec>完全遵循的scaleaxes参数的KVP编码语法 OGC WCS 2.0 Scaling Extension ,但仅限于整数比例因子。

即dim1_name(比例因子) [,dim2_name(scale_factor)] *

使用-scaleaxes与指定 view 数组中的选项。

-oo <NAME=VALUE>

3.4 新版功能.

Source dataset open option (format specific)

<src_dataset>

源数据集名称。

<dst_dataset>

目标文件名。

计算机辅助编程接口

此实用程序也可以通过 GDALMultiDimTranslate() .

实例

  • 将netCDF文件转换为多维VRT文件

$ gdalmdimtranslate in.nc out.vrt
  • 提取时间、Y、X数组的二维切片

$ gdalmdimtranslate in.nc out.tif -subset 'time("2010-01-01")' -array temperature
  • 沿X和Y轴的子样本

$ gdalmdimtranslate in.nc out.nc -scaleaxes "X(2),Y(2)"
  • 将时间、Y、X数组的值沿Y轴从上到下、从下到上(或反向)重新排序

$ gdalmdimtranslate in.nc out.nc -array "name=temperature,view=[:,::-1,:]"
  • 将具有X,Y,时间维度顺序的数组转换为时间,Y,X

$ gdalmdimtranslate in.nc out.nc -array "name=temperature,transpose=[2,1,0]"