GDALTINDEX(1) | GDAL | GDALTINDEX(1) |
gdaltindex - Builds a shapefile as a raster tileindex.
gdaltindex [--help] [--help-general] [-overwrite] [-recursive] [-filename_filter <val>]... [-min_pixel_size <val>] [-max_pixel_size <val>] [-f <format>] [-tileindex <field_name>] [-write_absolute_path] [-skip_different_projection] [-t_srs <target_srs>] [-src_srs_name <field_name>] [-src_srs_format {AUTO|WKT|EPSG|PROJ}] [-lyr_name <name>] [-lco <NAME>=<VALUE>]... [-gti_filename <name>] [-tr <xres> <yres>] [-te <xmin> <ymin> <xmax> <ymax>] [-ot <datatype>] [-bandcount <val>] [-nodata <val>[,<val>...]] [-colorinterp <val>[,<val>...]] [-mask] [-mo <KEY>=<VALUE>]... [-fetch_md <gdal_md_name> <fld_name> <fld_type>]... <index_file> <file_or_dir> [<file_or_dir>]...
This program creates an OGR-supported dataset with a record for each input raster file, an attribute containing the filename, and a polygon geometry outlining the raster. This output is suitable for use with MapServer as a raster tileindex, or as input for the GTI driver.
Overwrite the tile index if it already exists.
Whether directories specified in <file_or_dir> should be explored recursively.
Pattern that the filenames contained in directories pointed by <file_or_dir> 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" -filename_filter "*.tiff"
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 SRS defined by -t_srs.
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 SRS defined by -t_srs.
Layer creation option (format specific)
Starting with GDAL 3.9, this can also be a directory name. -recursive can also be used to recurse down to sub-directories.
It is also possible to use the generic option --optfile filelist.txt to specify a list of source files.
gdaltindex can be used to generate a tile index suitable for use by the GTI driver. There are two possibilities:
Formats that support layer metadata are for example GeoPackage (-f GPKG), FlatGeoBuf (-f FlatGeoBuf) or PostGIS (-f PG)
Setting -tr 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 SRS. Consequently, if input tiles may have different SRS, either -t_srs or -skip_different_projection should be specified.
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.
Target resolution in SRS unit per pixel.
Written in the XML Virtual Tile Index if -gti_filename is specified, or as RESX and RESY layer metadata items for formats that support layer metadata.
Target extent in SRS unit.
Written in the XML Virtual Tile Index if -gti_filename is specified, or as MINX, MINY, MAXX and MAXY layer metadata items for formats that support layer metadata.
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 -gti_filename is specified, or as DATA_TYPE layer metadata item for formats that support layer metadata.
Number of bands of the tiles of the tile index.
Written in the XML Virtual Tile Index if -gti_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 -colorinterp are specified and have multiple values, the band count is also inferred from that number.
Nodata value of the tiles of the tile index.
Written in the XML Virtual Tile Index if -gti_filename is specified, or as NODATA layer metadata item for formats that support layer metadata.
Color interpretation of of the tiles of the tile index: red, green, blue, alpha, gray, undefined.
Written in the XML Virtual Tile Index if -gti_filename is specified, or as COLOR_INTERPRETATION layer metadata item for formats that support layer metadata.
Whether tiles in the tile index have a mask band.
Written in the XML Virtual Tile Index if -gti_filename is specified, or as MASK_BAND layer metadata item for formats that support layer metadata.
Write an arbitrary layer metadata item, for formats that support layer metadata. This option may be repeated.
NOTE:
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: -fetch_md TIFFTAG_DATETIME creation_date DateTime
gdaltindex doq_index.shp doq/*.tif
gdaltindex -f GPKG doq_index.gpkg doq/*.tif
gdaltindex -t_srs EPSG:4326 -src_srs_name src_srs tile_index_mixed_srs.shp *.tif
gdaltindex tile_index.gti.gpkg -ot Byte -tr 60 60 -colorinterp Red,Green,Blue --optfile my_list.txt
This utility is also callable from C with GDALTileIndex().
Common options for raster programs for other command-line options, and in particular the --optfile switch that can be used to specify a list of input datasets.
Frank Warmerdam <warmerdam@pobox.com>
1998-2025
January 8, 2025 |