GDALLOCATIONINFO(1)
π GDALLOCATIONINFO π
okay so bestie, welcome to the gdallocationinfo page β that's section 1 of the GDAL manual, and yes it's literally the raster query tool. pull up a chair, we're gonna look at pixels together π
β¨ NAME β¨
gdallocationinfo β the raster query tool. that's it, that's the whole name. she's a query girlie and she knows it π
π¦ SYNOPSIS π¦
Usage: gdallocationinfo [--help-general] [-xml] [-lifonly] [-valonly]
[-b band]* [-overview overview_level]
[-l_srs srs_def] [-geoloc] [-wgs84]
[-oo NAME=VALUE]* srcfile [x y]
like, look at her. so many little flags. so much power. iykyk π₯
πΈ DESCRIPTION πΈ
so what does gdallocationinfo actually do? bestie. she gives you a whole mechanism to query information about a pixel given its location, and the location can be in one of a variety of coordinate systems. multiple reporting options? provided. she said "i contain multitudes" and she meant it β¨
-xmlβ the output report comes out all XML-formatted, which is chef's kiss for convenient post processing. ate π-lifonlyβ the only thing that gets printed is the filenames produced from the LocationInfo request against the database. i.e. this is your girl for identifying impacted files from a VRT. literally just the files, nothing else, periodt.-valonlyβ the only output is the pixel values of the selected pixel on each of the selected bands. no extra chatter. just numbers. iconic.-bband β selects a band to query. you can list multiple bands (see that*up in the synopsis? yeah, she's a repeater). by default, all bands are queried. slay.-overviewoverview_level β queries the (overview_level)th overview instead of the base band. sooverview_level=1is the 1st overview,2is the 2nd, you get the vibe π. important note: the x,y location β if the coordinate system is pixel/line β must still be given with respect to the base band. don't come for her about it, that's just how it works.-l_srssrs_def β this is where you tell her the coordinate system of the input x, y location. main character energy of the flag list ngl.-geolocβ indicates the input x,y points are in the georeferencing system of the image. π§-wgs84β indicates the input x,y points are WGS84 long, lat. note the order bestie, long first π-oo NAME=VALUEβ dataset open option, and it's format specific. again with the*, so stack 'em if you got 'em π- srcfile β the source GDAL raster datasource name.
- x β X location of the target pixel. by default the coordinate system is pixel/line unless
-l_srs,-wgs84or-geolocis supplied. - y β Y location of the target pixel. by default the coordinate system is pixel/line unless
-l_srs,-wgs84or-geolocis supplied.
π«Ά what she actually reports π«Ά
this utility is intended to provide a variety of information about a pixel, and currently she reports:
- the location of the pixel in pixel/line space.
- the result of a LocationInfo metadata 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
raster.mbtilesdriver. - the raster pixel value of that pixel for all or a subset of the bands.
- the unscaled pixel value if a
Scaleand/orOffsetapply to the band.
the pixel you're selecting is requested by x/y coordinate on the command line, or read from stdin. and here's the cute part β more than one coordinate pair can be supplied when you're reading coordinates from stdin. by default, pixel/line coordinates are expected. however π
with use of the -geoloc, -wgs84, or -l_srs switches, it's possible to specify the location in other coordinate systems.
the default report is in a human readable text format. but you can instead request XML output with the -xml switch, no cap.
and 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. she's helpful like that π
β¨ it is anticipated that additional reporting capabilities will be added to gdallocationinfo in the future. so like, watch this space bestie π
π EXAMPLES π
simple example, reporting on pixel (256,256) on the file utm.tif. easy. breezy.
$ gdallocationinfo utm.tif 256 256
Report:
Location: (256P,256L)
Band 1:
Value: 115
next up: querying a VRT file, providing the location in WGS84, and getting the result back in XML. look at that nesting, it's giving organized π₯
$ 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>
and the one where we read the location from stdin β this is the multi-coordinate moment i mentioned earlier π¦
$ 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
three reports, three values, zero stress. we love a pipe ππ
π AUTHOR π
Frank Warmerdam <warmerdam@pobox.com> β the author, the legend, we stan π
π COPYRIGHT π
1998-2026 β that's the copyright range, bestie, keep it in mind π«Ά
okay that's the whole page!! and a lil sign-off because you deserve it: this is from the GDAL manual and the page is dated Jan 08, 2026 β go query some pixels, you're gonna do amazing π
β¨π
π¦ where this page comes from
- epel 9: gdal3.4 3.4.3-5.el9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms