GDALLOCATIONINFO(1) | GDAL | GDALLOCATIONINFO(1) |
gdallocationinfo - Raster query tool.
Usage: gdallocationinfo [--help] [--help-general] [-xml] [-lifonly] [-valonly] [-E] [-field_sep <sep>] [-ignore_extra_input] [-b <band>]... [-overview <overview_level>] [-r {nearest|bilinear|cubic|cubicspline}] [[-l_srs <srs_def>] | [-geoloc] | [-wgs84]] [-oo <NAME>=<VALUE>]... <srcfile> [<x> <y>]
The gdallocationinfo utility provide a mechanism to query information about a pixel given its location in one of a variety of coordinate systems. Several reporting options are provided.
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.
Set this flag to avoid extra non-numeric content at end of input lines to be appended to the output lines in -valonly mode (requires -field_sep to be also defined), or as a dedicated field in default or -xml modes.
Enable Echo mode, where input coordinates are prepended to the output lines in -valonly mode.
Defines the field separator, used in -valonly mode, to separate different values. It defaults to the new-line character, which means that when querying a raster with several bands, the output will contain one value per line, which may make it hard to recognize which value belongs to which set of input x,y points when several ones are provided. Defining the field separator is also needed
This utility is intended to provide a variety of information about a pixel. Currently it reports:
The pixel selected is requested by x/y coordinate on the command line, or read from stdin. More than one coordinate pair can be supplied when reading coordinates from stdin. By default integer pixel/line coordinates are expected. However with use of the -geoloc, -wgs84, or -l_srs switches it is possible to specify the location in other coordinate systems.
The default report is in a human readable text format. It is possible to instead request xml output with the -xml switch.
For scripting purposes, the -valonly and -lifonly switches are provided to restrict output to the actual pixel values, or the LocationInfo files identified for the pixel.
It is anticipated that additional reporting capabilities will be added to gdallocationinfo in the future.
Simple example reporting on pixel (256,256) on the file utm.tif.
$ gdallocationinfo utm.tif 256 256 Report: Location: (256P,256L) Band 1: Value: 115
Query a VRT file providing the location in WGS84, and getting the result in xml.
$ gdallocationinfo -xml -wgs84 utm.vrt -117.5 33.75 <Report pixel="217" line="282"> <BandReport band="1"> <LocationInfo> <File>utm.tif</File> </LocationInfo> <Value>16</Value> </BandReport> </Report>
Reading location from stdin.
$ cat coordinates.txt 443020 3748359 441197 3749005 443852 3747743 $ cat coordinates.txt | gdallocationinfo -geoloc utmsmall.tif Report: Location: (38P,49L) Band 1: Value: 214 Report: Location: (7P,38L) Band 1: Value: 107 Report: Location: (52P,59L) Band 1: Value: 148 $ cat coordinates.txt | gdallocationinfo -geoloc -valonly -E -field_sep , utmsmall.tif 443020,3748359,214 441197,3749005,107 443852,3747743,148
Frank Warmerdam <warmerdam@pobox.com>
1998-2025
January 8, 2025 |