GDALLOCATIONINFO(1)

πŸ“¦
version 3.4.3 Β· 2 versions
, in epel 9

πŸ’… 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.
  • -b band β€” 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.
  • -overview overview_level β€” queries the (overview_level)th overview instead of the base band. so overview_level=1 is the 1st overview, 2 is 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_srs srs_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, -wgs84 or -geoloc is supplied.
  • y β€” Y location of the target pixel. by default the coordinate system is pixel/line unless -l_srs, -wgs84 or -geoloc is 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.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 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 πŸ’œ


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