# `gdal raster as-features`

Added in version 3.12.

Create features representing pixels of a raster

## Synopsis

    Usage: gdal raster as-features [OPTIONS] <INPUT> <OUTPUT>

    Create features from pixels of a raster dataset

    Positional arguments:
      -i, --input <INPUT>                                  Input raster datasets [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]

    Options:
      -f, --of, --format, --output-format <OUTPUT-FORMAT>  Output format ("GDALG" allowed)
      --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
      --update                                             Whether to open existing dataset in update mode
      --overwrite-layer                                    Whether overwriting existing output is allowed
      --append                                             Whether appending to existing layer is allowed
      --output-layer <OUTPUT-LAYER>                        Output layer name
      -b, --band <BAND>                                    Input band(s) (1-based index) [may be repeated]
      --geometry-type <GEOMETRY-TYPE>                      Geometry type. GEOMETRY-TYPE=none|point|polygon (default: none)
      --skip-nodata                                        Omit NoData pixels from the result
      --include-xy                                         Include fields for cell center coordinates
      --include-row-col                                    Include columns for row and column

    Advanced Options:
      --if, --input-format <INPUT-FORMAT>                  Input formats [may be repeated]
      --oo, --open-option <KEY>=<VALUE>                    Open options [may be repeated]
      --output-oo, --output-open-option <KEY>=<VALUE>      Output open options [may be repeated]

## Description

gdal raster as-features creates features representing the pixels in a raster dataset. Features may be created as polygons, points, or with no geometry at all. Unlike gdal raster polygonize, adjacent pixels having the same values are not combined.

This algorithm can be part of a gdal pipeline or gdal raster pipeline.

The following options are available:

--geometry-type

  Specifies the geometry type of the created features. Options available are "none" (default), "point", or "polygon".

--skip-nodata

  If set, no features will be emitted for pixels equal to the NoData value.

--include-xy

  If set, `CENTER_X` and `CENTER_Y` fields will be added with the center coordinates of each pixel.

--include-row-col

  If set, `ROW` and `COL` fields will be added with the cell positions.

-b <band>

  Specifies the bands for which pixel values should be added as fields of the created features. By default, values will be added for all bands.

-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, --creation-option <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.

--overwrite

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

## Examples

### Example 1: Create points at the center of pixels having a value less than 150

    gdal pipeline read input.tif !
             reclassify -m "[-inf, 150)=1; DEFAULT=NO_DATA" !
             as-features --geometry-type point --skip-nodata !
             write out.shp