GDAL-RASTER-PIXEL-INFO(1)

NAME
gdal-raster-pixel-info - Return information on a pixel of a raster dataset

Added in version 3.11.

SYNOPSIS

    Usage: gdal raster pixel-info [OPTIONS] <INPUT> [<column,line> or <X,Y>]
    Return information on a pixel of a raster dataset.
    Positional arguments:
      -i, --dataset, --input <INPUT>                       Input raster datasets [required]
      -p, --pos, --position <column,line> or <X,Y>         Pixel position [may be repeated]
                                                           Mutually exclusive with --position-dataset
    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 (default is 'GeoJSON' if 'position-dataset' not specified) [not available in pipelines]
      --position-dataset <POSITION-DATASET>                Vector dataset with coordinates
                                                           Mutually exclusive with --position
      -l, --layer, --input-layer <INPUT-LAYER>             Input layer name
      -o, --output <OUTPUT>                                Output vector dataset (created by algorithm)
      --co, --creation-option <KEY>=<VALUE>                Creation option [may be repeated] [not available in pipelines]
      --lco, --layer-creation-option <KEY>=<VALUE>         Layer creation option [may be repeated] [not available in pipelines]
      --overwrite                                          Whether overwriting existing output dataset is allowed [not available in pipelines]
      -b, --band <BAND>                                    Input band(s) (1-based index) [may be repeated]
      --overview <OVERVIEW>                                Which overview level of source file must be used
      --position-crs <POSITION-CRS>                        CRS of position (default is 'pixel' if 'position-dataset' not specified)
      -r, --resampling <RESAMPLING>                        Resampling algorithm for interpolation. RESAMPLING=nearest|bilinear|cubic|cubicspline (default: nearest)
      --promote-pixel-value-to-z                           Whether to set the pixel value as Z component of GeoJSON geometry
      --include-field <INCLUDE-FIELD>                      Fields from coordinate dataset to include in output (special values: ALL and NONE) (default: ALL) [may be repeated]
    Advanced Options:
      --oo, --open-option <KEY>=<VALUE>                    Open options [may be repeated] [not available in pipelines]
      --if, --input-format <INPUT-FORMAT>                  Input formats [may be repeated] [not available in pipelines]

DESCRIPTION

gdal raster pixel-info provide a mechanism to query information about a pixel given its location in one of a variety of coordinate systems.

The following items will be reported (when known):

•   Input coordinates

•   Input coordinates converted to column, line

•   Pixel value per selected band(s), with unscaled value

•   For VRT files, which file(s) contribute to the pixel value (only for GeoJSON output)

    There are 3 possible ways of providing input location(s):

•   from input stream, with a "X Y" pair per line, potentially followed by other text.

•   though the --position argument.

•   through a GDAL vector dataset through the --position-dataset argument.

    There are 2 possibilities of outputting pixel information:

•   either on the output stream as CSV or GeoJSON (default to GeoJSON)

•   or as a GDAL vector dataset whose name is specified with the --output argument.

    Since GDAL 3.13, this algorithm can be part of a gdal pipeline. In that case, only reading coordinates from a GDAL vector dataset and outputting results to one is supported.

    Added in version 3.13.

GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET)

This program supports serializing the command line as a JSON file using the GDALG output format. The resulting file can then be opened as a vector dataset using the GDALG: GDAL Streamed Algorithm driver, and apply the specified pipeline in a on-the-fly / streamed way.

NOTE: However this algorithm is not natively streaming compatible. Consequently a in-memory temporary dataset will be generated, which may cause significant processing time at opening.

The following options are available:

PROGRAM-SPECIFIC OPTIONS

-b <band>
    Selects a band to query. Multiple bands can be listed. By default all bands are queried.

-f, --of, --format, --output-format <FORMAT>
    Which vector output format to use.

    When --output is not specified, csv or geojson are the only two supported choices, with geojson being the default. Otherwise, any GDAL-supported vector format with write capabilities is supported.

--position-dataset <COORDINATE-DATASET>
    Added in version 3.13.

    GDAL-compatible vector dataset from which input coordinates are read. If the input feature has a point geometry, its location is used to query the raster. For other geometry types, the centroid is used. To read all pixel values for non-point geometries, use gdal raster zonal-stats. By default, all attribute fields are copied to the output.

    If the --position-crs argument is specified, the coordinates of the point are interpreted according to the value of that argument.

    Otherwise, if the input vector layer has a CRS, coordinates are assumed to be expressed in it.

    Otherwise, coordinates are assumed to be in the CRS raster dataset if it has a CRS.

    Otherwise, coordinates are assumed to be expressed in the column,line raster space.

-l, --layer, --input-layer <INPUT-LAYER>
    Added in version 3.13.

    Input layer name of the dataset specified with --position-dataset to use.

-o, --output <OUTPUT>
    Added in version 3.13.

    Output vector dataset (created by algorithm)

--include-field <FIELD>
    Added in version 3.13.

    Name of the field(s) from --position-dataset to include into the output. By default, all fields are included (which corresponds to special value ALL). Special value NONE can be used to mean that no field from the position dataset must be included in the output.

--ovr, --overview <index>
    Query the (overview_level)th overview (overview_level=0 is the 1st overview), instead of the base band. Note that the x,y location (if the coordinate system is pixel/line) must still be given with respect to the base band.

-p, --pos, --position <column,line> or <X,Y>
    Required, if --position-dataset is not specified and no content is provided through the input stream.

    This can be specified either as an option, a positional value after the dataset name, or when called from gdal, as (space separated) values provided on the standard input.

    By default, when --position-crs is not specified, or set to pixel, this is a column, line tuple (possibly with fractional part). If --position-crs is set to dataset, this is a georeferenced coordinate expressed in the CRS of the dataset. If --position-crs is specified to a CRS definition, this is a georeferenced coordinate expressed in this CRS.

    X means always longitude or easting, Y means always latitude or northing.

    Several x,y tuples may be specified.

--position-crs pixel|dataset|<crs-def>
    CRS of position, or one of two following special values:

•   pixel means that the position is set as column, line (default)

•   dataset means that the position is a georeferenced coordinate expressed in the CRS of the dataset.

--promote-pixel-value-to-z
    Added in version 3.13.

    Whether to set the pixel value as Z component of GeoJSON geometry. Only applies if a single band is selected, and for GeoJSON output format.

-r, --resampling nearest|bilinear|cubic|cubicspline
    Select a sampling algorithm. The default is nearest.

    The available methods are:

•   nearest applies a nearest neighbour.

•   bilinear applies a bilinear convolution kernel.

•   cubic applies a cubic convolution kernel.

•   cubicspline applies a B-Spline convolution kernel.

STANDARD OPTIONS

--oo, --open-option <NAME>=<VALUE>
    Dataset open option (format specific).

    May be repeated.

--if, --input-format <format>
    Format/driver name to be attempted to open the input file(s). It is generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate driver. This option can be repeated several times to specify several candidate drivers. Note that it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions.

    May be repeated.

--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.

--lco, --layer-creation-option <NAME>=<VALUE>
    Many formats have one or more optional layer creation options that can be used to control particulars about the layer created. For instance, the GeoPackage driver supports layer creation options to control the feature identifier or geometry column name, setting the identifier or description, etc.

    May be repeated.

    The layer creation options available vary by format driver, and some simple formats have no layer 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 Vector drivers format specific documentation for legal creation options for each format.

    Note that layer creation options are different from dataset creation options.

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

RETURN STATUS CODE

The program returns status code 0 in case of success, and non-zero in case of error (non-blocking errors emitted as warnings are considered as a successful execution).

EXAMPLES

  Example 1: Reporting on pixel column=5, line=10 on the file byte.tif

    $ gdal raster pixel-info byte.tif 5 10
    {
      "type":"FeatureCollection",
      "crs":{
        "type":"name",
        "properties":{
          "name":"urn:ogc:def:crs:EPSG::26711"
        }
      },
      "features":[
        {
          "type":"Feature",
          "properties":{
            "input_coordinate":[
              5.0,
              10.0
            ],
            "column":5.0,
            "line":10.0,
            "bands":[
              {
                "band_number":1,
                "raw_value":132,
                "unscaled_value":132.0
              }
            ]
          },
          "geometry":{
            "type":"Point",
            "coordinates":[
              441020.0,
              3750720.0
            ]
          }
        }
      ]
    }

  Example 2: Reporting on point at UTM 11N coordinates easting=441320 and northing=3750720 on the file byte.tif

    $ gdal raster pixel-info --position-crs=dataset byte.tif 441320 3750720
    {
      "type":"FeatureCollection",
      "crs":{
        "type":"name",
        "properties":{
          "name":"urn:ogc:def:crs:EPSG::26711"
        }
      },
      "features":[
        {
          "type":"Feature",
          "properties":{
            "input_coordinate":[
              441320.0,
              3750720.0
            ],
            "column":10.0,
            "line":10.0,
            "bands":[
              {
                "band_number":1,
                "raw_value":115,
                "unscaled_value":115.0
              }
            ]
          },
          "geometry":{
            "type":"Point",
            "coordinates":[
              441320.0,
              3750720.0
            ]
          }
        }
      ]
    }

  Example 3: Reporting on point at WGS84 coordinates longitude=-117.6355 and latitude=33.8970 on the file byte.tif, with CSV output format

    $ gdal raster pixel-info --of=csv --position-crs=WGS84 byte.tif -117.6355 33.8970
    geom_x,geom_y,extra_content,column,line,band_1_raw_value,band_1_unscaled_value
    -117.6355,33.897,,10.020546288988,9.98330473474925,115,115

  Example 4: Reporting on point at WGS84 coordinates provided on the standard input with longitude, latitude order.

    $ echo -117.6355 33.8970 | gdal raster pixel-info --of=csv --position-crs=WGS84 byte.tif
    geom_x,geom_y,extra_content,column,line,band_1_raw_value,band_1_unscaled_value
    -117.6355,33.897,,10.020546288988,9.98330473474925,115,115

  Example 5: Reading coordinates to extract from an input GeoPackage file and writing the output to a GeoPackage file

    gdal raster pixel-info --position-dataset input.gpkg --input byte.tif --output output.gpkg

  Example 6: Getting pixel values from a on-the-fly resized raster dataset from coordinates in input.gpkg.

    gdal pipeline read byte.tif ! resize --size 50%,50% -r cubic ! pixel-info input.gpkg ! write output.gpkg

  Example 7: Getting pixel values from coordinates in a piped vector dataset, using the _ placeholder dataset name

    gdal pipeline read input.gml ! swap-xy ! pixel-info --input byte.tif --position-dataset _ ! write output.gpkg

AUTHOR
Even Rouault <even.rouault@spatialys.com>

COPYRIGHT
1998-2026