GDALTINDEX(1) | GDAL | GDALTINDEX(1) |
NAME¶
gdaltindex - Builds a shapefile as a raster tileindex.
SYNOPSIS¶
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>]...
DESCRIPTION¶
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.
- --help
- Show this help message and exit
- --help-general
- Gives a brief usage message for the generic GDAL commandline options and exit.
- -overwrite
- New in version 3.9.
Overwrite the tile index if it already exists.
- -recursive
- New in version 3.9.
Whether directories specified in <file_or_dir> should be explored recursively.
- -filename_filter <val>
- New in version 3.9.
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"
- -min_pixel_size <val>
- New in version 3.9.
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.
- -max_pixel_size <val>
- New in version 3.9.
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.
- -f <format>
- The OGR format of the output tile index file. Starting with GDAL 2.3, if not specified, the format is guessed from the extension (previously was ESRI Shapefile).
- -tileindex <field_name>
- The output field name to hold the file path/location to the indexed rasters. The default tile index field name is location.
- -write_absolute_path
- The absolute path to the raster files is stored in the tile index file. By default the raster filenames will be put in the file exactly as they are specified on the command line.
- -skip_different_projection
- Only files with same projection as files already inserted in the tileindex will be inserted (unless -t_srs is specified). Default does not check projection and accepts all inputs.
- -t_srs <target_srs>
- 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.
- -src_srs_name <field_name>
- The name of the field to store the SRS of each tile. This field name can be used as the value of the TILESRS keyword in MapServer
- -src_srs_format {AUTO|WKT|EPSG|PROJ}
- The format in which the SRS of each tile must be written. Types can be AUTO, WKT, EPSG, PROJ. This option should be used together with -src_srs_format.
- -lyr_name <name>
- Layer name to create/append to in the output tile index file.
- -lco <NAME>=<VALUE>
- New in version 3.9.
Layer creation option (format specific)
- <index_file>
- The name of the output file to create/append to. The default dataset will be created if it doesn't already exist, otherwise it will append to the existing dataset.
- <file_or_dir>
- The input GDAL raster files, can be multiple files separated by spaces.
Wildcards may also be used. Stores the file locations in the same style as
specified here, unless -write_absolute_path option is also used.
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.
OPTIONS SPECIFIC TO USE BY THE GDAL GTI DRIVER¶
gdaltindex can be used to generate a tile index suitable for use by the GTI driver. There are two possibilities:
- either use directly a vector tile index generated by gdaltindex 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 (-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.
- -gti_filename <name>
- New in version 3.9.
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.
- -tr <xres> <yres>
- New in version 3.9.
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.
- -te <xmin> <ymin> <xmax> <ymax>
- New in version 3.9.
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.
- -ot <datatype>
- New in version 3.9.
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.
- -bandcount <val>
- New in version 3.9.
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 <val>[,<val>...]
- New in version 3.9.
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.
- -colorinterp <val>[,<val>...]
- New in version 3.9.
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.
- -mask
- New in version 3.9.
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.
- -mo <KEY>=<VALUE>
- New in version 3.9.
Write an arbitrary layer metadata item, for formats that support layer metadata. This option may be repeated.
NOTE:
- -fetch_md <gdal_md_name> <fld_name> <fld_type>
- New in version 3.9.
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
EXAMPLES¶
- •
- Produce a shapefile (doq_index.shp) with a record for every image that the utility found in the doq folder. Each record holds information that points to the location of the image and also a bounding rectangle shape showing the bounds of the image:
gdaltindex doq_index.shp doq/*.tif
- •
- Perform the same command as before, but now we create a GeoPackage instead of a Shapefile.
gdaltindex -f GPKG doq_index.gpkg doq/*.tif
- •
- The -t_srs option can also be used to transform all input rasters into the same output projection:
gdaltindex -t_srs EPSG:4326 -src_srs_name src_srs tile_index_mixed_srs.shp *.tif
- •
- Make a tile index from files listed in a text file, with metadata suitable for use by the GDAL GTI / Virtual Raster Tile Index driver.
gdaltindex tile_index.gti.gpkg -ot Byte -tr 60 60 -colorinterp Red,Green,Blue --optfile my_list.txt
C API¶
This utility is also callable from C with GDALTileIndex().
SEE ALSO¶
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.
AUTHOR¶
Frank Warmerdam <warmerdam@pobox.com>
COPYRIGHT¶
1998-2024
November 1, 2024 |