# `gdal driver gti create`

Added in version 3.11.

Create an index of raster datasets compatible of the GDAL Tile Index (GTI) driver.

## Synopsis

    Usage: gdal driver gti create [OPTIONS] <INPUT>... <OUTPUT>

    Create an index of raster datasets compatible of the GDAL Tile Index (GTI) driver.

    Positional arguments:
      -i, --input <INPUT>                                              Input raster datasets [may be repeated] [required]
      -o, --output <OUTPUT>                                            Output vector dataset [required]

    Common Options:
      -h, --help                                                       Display help message and exit
      --json-usage                                                     Display usage as JSON document and exit
      --config <KEY>=<VALUE>                                           Configuration option [may be repeated]
      --progress                                                       Display progress bar

    Options:
      -f, --of, --format, --output-format <OUTPUT-FORMAT>              Output format
      --co, --creation-option <KEY>=<VALUE>                            Creation option [may be repeated]
      --lco, --layer-creation-option <KEY>=<VALUE>                     Layer creation option [may be repeated]
      --overwrite                                                      Whether overwriting existing output is allowed
                                                                       Mutually exclusive with --update
      --update                                                         Whether to open existing dataset in update mode
                                                                       Mutually exclusive with --overwrite
      --overwrite-layer                                                Whether overwriting existing layer is allowed
      --append                                                         Whether appending to existing layer is allowed
      -l, --nln, --layer <LAYER>                                       Layer name
      --recursive                                                      Whether input directories should be explored recursively.
      --filename-filter <FILENAME-FILTER>                              Pattern that the filenames in input directories should follow ('*' and '?' wildcard) [may be repeated]
      --min-pixel-size <MIN-PIXEL-SIZE>                                Minimum pixel size in term of geospatial extent per pixel (resolution) that a raster should have to be selected.
      --max-pixel-size <MAX-PIXEL-SIZE>                                Maximum pixel size in term of geospatial extent per pixel (resolution) that a raster should have to be selected.
      --location-name <LOCATION-NAME>                                  Name of the field with the raster path (default: location)
      --absolute-path                                                  Whether the path to the input datasets should be stored as an absolute path
      --dst-crs <DST-CRS>                                              Destination CRS
      --metadata <KEY>=<VALUE>                                         Add dataset metadata item [may be repeated]
      --xml-filename <XML-FILENAME>                                    Filename of the XML Virtual Tile Index file to generate, that can be used as an input for the GDAL GTI / Virtual Raster Tile Index driver
      --resolution <xres>,<yres>                                       Resolution (in destination CRS units) of the virtual mosaic
      --bbox <BBOX>                                                    Bounding box (in destination CRS units) of the virtual mosaic
      --ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE>          Datatype of the virtual mosaic. OUTPUT-DATA-TYPE=Byte|Int8|UInt16|Int16|UInt32|Int32|UInt64|Int64|CInt16|CInt32|Float16|Float32|Float64|CFloat32|CFloat64
      --band-count <BAND-COUNT>                                        Number of bands of the virtual mosaic
      --nodata <NODATA>                                                Nodata value(s) of the bands of the virtual mosaic [may be repeated]
      --color-interpretation <COLOR-INTERPRETATION>                    Color interpretation(s) of the bands of the virtual mosaic. COLOR-INTERPRETATION=red|green|blue|alpha|gray|undefined [may be repeated]
      --mask                                                           Defines that the virtual mosaic has a mask band
      --fetch-metadata <gdal-metadata-name>,<field-name>,<field-type>  Fetch a metadata item from source rasters and write it as a field in the index. [may be repeated]

## Description

gdal driver gti create creates a vector dataset with a record for each input raster file, an attribute containing the filename, and a polygon geometry outlining the raster, to be used as input for the GTI driver.

This is an extension of gdal raster index.

There are two possibilities:

- either use directly a vector tile index generated by gdal driver gti create as the input of the GTI driver

- or generate a small XML .gti wrapper file, for easier use with non-file-based formats such as databases, or for vector formats that do not support setting layer metadata items.

Formats that support layer metadata are for example GeoPackage (`--of GPKG`), FlatGeoBuf (`--of FlatGeoBuf`) or PostGIS (`--of PG`)

Setting `--resolution` and `--ot` is recommended to avoid the GTI driver to have to deduce them by opening the first tile in the index. If the tiles have nodata or mask band, `--nodata` and `--mask` should also be set.

In a GTI context, the extent of all tiles referenced in the tile index must be expressed in a single CRS. Consequently, if input tiles may have different CRS, `--dst-crs` must be specified.

The following options are available:

### Standard options

-f, --of, --format, --output-format <OUTPUT-FORMAT>

  Which output vector format to use. Allowed values may be given by `gdal --formats | grep vector | grep rw | sort`

--co <NAME>=<VALUE>

  Many formats have one or more optional creation options that can be used to control particulars about the file created. For instance, the GeoTIFF driver supports creation options to control compression, and whether the file should be tiled.

  May be repeated.

  The creation options available vary by format driver, and some simple formats have no creation options at all. A list of options supported for a format can be listed with the --formats command line option but the documentation for the format is the definitive source of information on driver creation options. See Raster drivers format specific documentation for legal creation options for each format.

-lco <NAME>=<VALUE>

  Layer creation option (format specific)

--overwrite

  Allow program to overwrite existing target file or dataset. Otherwise, by default, gdal errors out if the target file or dataset already exists.

--update

  Whether the output dataset must be opened in update mode. Implies that it already exists.

--overwrite-layer

  Whether overwriting the existing output vector layer is allowed.

--append

  Whether appending features to the existing output vector layer is allowed

-l, --nln, --layer <LAYER>

  Provides a name for the output vector layer.

--recursive

  Whether input directories should be explored recursively.

--filename-filter <FILENAME-FILTER>

  Pattern that the filenames contained in input directories should follow. '*' is a wildcard character that matches any number of any characters including none. '?' is a wildcard character that matches a single character. Comparisons are done in a case insensitive way. Several filters may be specified.

  For example: `--filename-filter "*.tif,*.tiff"`

--min-pixel-size <val>

  Minimum pixel size in term of geospatial extent per pixel (resolution) that a raster should have to be selected. The pixel size is evaluated after reprojection of its extent to the target CRS defined by `--dst-crs`.

--max-pixel-size <val>

  Maximum pixel size in term of geospatial extent per pixel (resolution) that a raster should have to be selected. The pixel size is evaluated after reprojection of its extent to the target CRS defined by `--dst-crs`.

-location-name <LOCATION-NAME>

  The output field name to hold the file path/location to the indexed rasters. The default field name is `location`.

--absolute-path

  The absolute path to the raster files is stored in the index file. By default the raster filenames will be put in the file exactly as they are specified on the command line.

--dst-crs <DST-CRS>

  Geometries of input files will be transformed to the desired target coordinate reference system. Default creates simple rectangular polygons in the same coordinate reference system as the input rasters.

--metadata <KEY>=<VALUE>

  Write an arbitrary layer metadata item, for formats that support layer metadata. This option may be repeated.

--xml-filename <name>

  Filename of the XML Virtual Tile Index file to generate, that can be used as an input for the GDAL GTI / Virtual Raster Tile Index driver. This can be useful when writing the tile index in a vector format that does not support writing layer metadata items.

--resolution <xres,<yres>

  Target resolution in CRS unit per pixel.

  Written in the XML Virtual Tile Index if `--xml-filename` is specified, or as `RESX` and `RESY` layer metadata items for formats that support layer metadata.

--bbox <xmin>,<ymin>,<xmax>,<ymax>

  Target extent in CRS unit.

  'x' is longitude values for geographic CRS and easting for projected CRS. 'y' is latitude values for geographic CRS and northing for projected CRS.

  Written in the XML Virtual Tile Index if `--xml-filename` is specified, or as `MINX`, `MINY`, `MAXX` and `MAXY` layer metadata items for formats that support layer metadata.

--ot, --datatype, --output-data-type <datatype>

  Data type of the tiles of the tile index: `Byte`, `Int8`, `UInt16`, `Int16`, `UInt32`, `Int32`, `UInt64`, `Int64`, `Float32`, `Float64`, `CInt16`, `CInt32`, `CFloat32` or `CFloat64`

  Written in the XML Virtual Tile Index if `--xml-filename` is specified, or as `DATA_TYPE` layer metadata item for formats that support layer metadata.

--band-count <val>

  Number of bands of the tiles of the tile index.

  Written in the XML Virtual Tile Index if `--xml-filename` is specified, or as `BAND_COUNT` layer metadata item for formats that support layer metadata.

  A mix of tiles with N and N+1 bands is allowed, provided that the color interpretation of the (N+1)th band is alpha. The N+1 value must be written as the band count in that situation.

  If `--nodata` or `--color-interpretation` are specified and have multiple values, the band count is also inferred from that number.

--nodata <val>[,<val>...]

  Nodata value of the tiles of the tile index.

  Written in the XML Virtual Tile Index if `--xml-filename` is specified, or as `NODATA` layer metadata item for formats that support layer metadata.

--color-interpretation <val>[,<val>...]

  Color interpretation of of the tiles of the tile index: `red`, `green`, `blue`, `alpha`, `gray`, `undefined`.

  Written in the XML Virtual Tile Index if `--xml-filename` is specified, or as `COLOR_INTERPRETATION` layer metadata item for formats that support layer metadata.

--mask

  Whether tiles in the tile index have a mask band.

  Written in the XML Virtual Tile Index if `--xml-filename` is specified, or as `MASK_BAND` layer metadata item for formats that support layer metadata.

--fetched-metadata <gdal_md_name>,<fld_name>,<fld_type>

  Fetch a metadata item from the raster tile and write it as a field in the tile index.

  <gdal_md_name> should be the name of the raster metadata item. `{PIXEL_SIZE}` may be used as a special name to indicate the pixel size.

  <fld_name> should be the name of the field to create in the tile index.

  <fld_type> should be the name of the type to create. One of `String`, `Integer`, `Integer64`, `Real`, `Date`, `DateTime`

  This option may be repeated.

  For example: `--fetched-metadata TIFFTAG_DATETIME,creation_date,DateTime`

## Examples

### Example 1

Make a tile index from GeoTIFF files, with metadata suitable for use by the GDAL GTI / Virtual Raster Tile Index driver.

    gdal driver gti create --ot Byte --resolution=60,60 --band-count=3 --color-interpretation=Red,Green,Blue *.tif tile_index.gti.gpkg