# gdal_footprint

Added in version 3.8.0.

Compute footprint of a raster.

## Synopsis

    Usage: gdal_footprint [--help] [--long-usage] [--help-general]
                          [-b <band>]... [-combine_bands VAR]
                          [[-ovr <index>]|[-srcnodata "<value>[ <value>]..."]]
                          [-t_cs VAR] [-t_srs <srs_def>] [-split_polys]
                          [-convex_hull] [-densify <value>] [-simplify <value>]
                          [-min_ring_area <value>] [-max_points <value>|unlimited]
                          [--quiet] [-oo <NAME>=<VALUE>]... [-of <output_format>]
                          [[-location_field_name <field_name>]|[-no_location]]
                          [-write_absolute_path] [-lco <NAME>=<VALUE>]...
                          [-dsco <NAME>=<VALUE>]... [-lyr_name <value>] [-overwrite]
                          <src_filename> <dst_filename>

## Description

The gdal_footprint utility can be used to compute the footprint of a raster file, taking into account nodata values (or more generally the mask band attached to the raster bands), and generating polygons/multipolygons corresponding to areas where pixels are valid, and write to an output vector file.

The nearblack utility may be run as a pre-processing step to generate proper mask bands.

Tip

Equivalent in new "gdal" command line interface:

See gdal raster footprint.

--help

  Show this help message and exit

--help-general

  Gives a brief usage message for the generic GDAL commandline options and exit.

-b <band>

  Band(s) of interest. Between 1 and the number of bands of the raster. May be specified multiple times. If not specified, all bands are taken into account. The way multiple bands are combined is controlled by `-combine_bands`

-combine_bands union|intersection

  Defines how the mask bands of the selected bands are combined to generate a single mask band, before being vectorized. The default value is `union`: that is a pixel is valid if it is valid at least for one of the selected bands. `intersection` means that a pixel is valid only if it is valid for all selected bands.

-ovr <index>

  To specify which overview level of source file must be used, when overviews are available on the source raster. By default the full resolution level is used. The index is 0-based, that is 0 means the first overview level. This option is mutually exclusive with `-srcnodata`.

-srcnodata "<value>[ <value>]..."

  Set nodata values for input bands (different values can be supplied for each band). If a single value is specified, it applies to all selected bands. If more than one value is supplied, there should be as many values as the number of selected bands, and all values should be quoted to keep them together as a single operating system argument. If the option is not specified, the intrinsic mask band of each selected bands will be used.

-t_cs pixel|georef

  Target coordinate system. By default if the input dataset is georeferenced, `georef` is implied, that is the footprint geometry will be expressed as coordinates in the CRS of the raster (or the one specified with `-t_srs`). If specifying `pixel`, the coordinates of the footprint geometry are column and line indices.

-t_srs <srs_def>

  Target CRS of the output file. The <srs_def> may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n or a file containing the WKT. Specifying this option implies -t_cs georef The footprint is reprojected from the CRS of the source raster to the specified CRS.

-split_polys

  When specified, multipolygons are split as several features each with one single polygon.

-convex_hull

  When specified, the convex hull of (multi)polygons is computed.

-densify <value>

  The specified value of this option is the maximum distance between 2 consecutive points of the output geometry. The unit of the distance is in pixels if `-t_cs` equals `pixel`, or otherwise in georeferenced units of the source raster. This option is applied before the reprojection implied by `-t_srs`.

-simplify <value>

  The specified value of this option is the tolerance used to merge consecutive points of the output geometry using the `OGRGeometry::Simplify()` method. The unit of the distance is in pixels if `-t_cs` equals `pixel`, or otherwise in georeferenced units of the target vector dataset. This option is applied after the reprojection implied by `-t_srs`.

-min_ring_area <value>

  Minimum value for the area of a ring The unit of the area is in square pixels if `-t_cs` equals `pixel`, or otherwise in georeferenced units of the target vector dataset. This option is applied after the reprojection implied by `-t_srs`

-max_points <value>|unlimited

  Maximum number of points of each output geometry (not counting the closing point of each ring, which is always identical to the first point). The default value is 100. `unlimited` can be used to remove that limitation.

-q

  Suppress progress monitor and other non-error output.

-oo <NAME>=<VALUE>

  Dataset open option (format specific)

-of <ogr_format>

  Select the output format. Use the short format name. Guessed from the file extension if not specified

-location_field_name <field_name>

  Added in version 3.9.0.

  Specifies the name of the field in the resulting vector dataset where the path of the input dataset will be stored. The default field name is "location". To prevent writing the path of the input dataset, use `-no_location`

-no_location

  Added in version 3.9.0.

  Turns off the writing of the path of the input dataset as a field in the output vector dataset.

-write_absolute_path

  Added in version 3.9.0.

  Enables writing the absolute path of the input dataset. By default, the filename is written in the location field exactly as specified on the command line.

-lco <NAME>=<VALUE>

  Layer creation option (format specific)

-dsco <NAME>=<VALUE>

  Dataset creation option (format specific)

-lyr_name <value>

  Name of the target layer. `footprint` if not specified.

-overwrite

  Overwrite the target layer if it exists.

<src_filename>

  The source raster file name.

<dst_filename>

  The destination vector file name. If the file and the output layer exist, the new footprint is appended to them, unless `-overwrite` is used.

Post-vectorization geometric operations are applied in the following order:

- optional splitting (`-split_polys`)

- optional densification (`-densify`)

- optional reprojection (`-t_srs`)

- optional filtering by minimum ring area (`-min_ring_area`)

- optional application of convex hull (`-convex_hull`)

- optional simplification (`-simplify`)

- limitation of number of points (`-max_points`)

## C API

This utility is also callable from C with `GDALFootprint()`.

## Examples

### Example 1: Compute the footprint of a GeoTIFF file as a GeoJSON file

    gdal_footprint -t_srs EPSG:4326 input.tif output.geojson

The footprint will be written using WGS84 longitude, latitude coordinates, regardless of the spatial reference system used by the input raster.