GDALLOCATIONINFO(1)
π gdallocationinfo(1) π
okay so bestie, this is a page from the GDAL manual, section 1 β and it's literally a raster query tool. It gives you the tea on any pixel you point at, no cap. β¨
πΈ NAME πΈ
gdallocationinfo β Raster query tool. That's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
Here's the shape of the whole thing, copied exactly so you can screenshot it:
Usage: gdallocationinfo [--help] [--long-usage] [--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>
π DESCRIPTION π
So the whole thing about gdallocationinfo is that it's a mechanism to query information about a pixel given its location β and you get to pick which coordinate system you're speaking in, because there's genuinely a variety of them. Several reporting options are provided too. It's giving β¨optionsβ¨.
TIP: there's an equivalent in the newgdalcommand line interface: Seegdal raster pixel-info.
Now, the options, one by one, and yes, every single one, because we do not skip. π
--helpβ shows this help message and exits. a classic.--help-generalβ gives you a brief usage message for the generic GDAL commandline options, then exits.-xmlβ the output report gets XML formatted so you can conveniently post process it. (Example 2 has the receipts.)-lifonlyβ the only output is filenames production from theLocationInforequest against the database (i.e. for identifying impacted file from VRT). Just the files, nothing else.-valonlyβ the only output is the pixel values of the selected pixel on each of the selected bands. By default, the value of each band is output on a separate line β unless-field_sepis specified. π«Ά-b <band>β selects a band to query. You can list multiple bands. By default all bands are queried.-r {nearest|bilinear|cubic|cubicspline}β added in version 3.10. Select a sampling algorithm. The default isnearest. The available methods are:nearestapplies a nearest neighbour.bilinearapplies a bilinear convolution kernel.cubicapplies a cubic convolution kernel.cubicsplineapplies a B-Spline convolution kernel.
-overview <overview_level>β queries the (overview_level)th overview (sooverview_level=1is the 1st overview), instead of the base band. Heads up bestie: the x,y location (if the coordinate system is pixel/line) must still be given with respect to the base band. π-l_srs <srs_def>β the coordinate system of the input x, y location.-geolocβ indicates input x,y points are in the georeferencing system of the image.-wgs84β indicates input x,y points are WGS84 long, lat.-oo <NAME>=<VALUE>β Dataset open option (format specific).-ignore_extra_inputβ added in version 3.9. Set this flag to avoid extra non-numeric content at end of input lines being appended to the output lines in-valonlymode (requires-field_septo be also defined), or as a dedicated field in default or-xmlmodes.-Eβ added in version 3.9. Enables Echo mode, where input coordinates are prepended to the output lines in-valonlymode.-field_sep <sep>β added in version 3.9. Defines the field separator, used in-valonlymode, 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<srcfile>β the source GDAL raster datasource name.<x>β X location of target pixel. By default the coordinate system is pixel/line unless-l_srs,-wgs84or-geolocsupplied.<y>β Y location of target pixel. By default the coordinate system is pixel/line unless-l_srs,-wgs84or-geolocsupplied.
This utility is intended to provide a variety of information about a pixel. Currently it reports:
- The location of the pixel in pixel/line space.
- The result of a
LocationInfometadata query against the datasource. This is implemented for VRT files β which will report the file(s) used to satisfy requests for that pixel β and by the MBTiles driver. - The raster pixel value of that pixel for all or a subset of the bands.
- The unscaled pixel value if a Scale and/or Offset apply to the band.
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. Scripting besties stay winning. π
It is anticipated that additional reporting capabilities will be added to gdallocationinfo in the future. the future is bright β¨
β 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). So like, a little warning is not the drama. π
π EXAMPLES π
πΈ Example 1: Reporting on pixel (256,256) on the file utm.tif
$ gdallocationinfo utm.tif 256 256
Report:
Location: (256P,256L)
Band 1:
Value: 115
π¦ Example 2: Querying 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>
π Example 3: Reading locations 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
π AUTHOR π
Frank Warmerdam <warmerdam@pobox.com>
π COPYRIGHT π
1998-2026
okay that's the whole page bestie, you ate it π«Ά this was the GDAL manual, Aug 18, 2026 edition β go query some pixels, they're literally waiting for you. πβ¨π
π¦ where this page comes from
- alpine 3.24: gdal-doc 3.13.3-r0 Β· MIT
- arch rolling: gdal 3.13.3-6 Β· MIT
- ubuntu stonking: gdal-bin 3.13.3+dfsg-1ubuntu4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms