5

I have a GeoTIFF with the following meta information:

PROJCS["WGS 84 / Pseudo-Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],
    AUTHORITY["EPSG","3857"]]

How to I find the geographic coordinate (lat, lon) in Web Mercator of a pixel in the image (e.g. x=500, y=600)

2
  • That's just the projection information - the metadata report should also contain an origin coordinate and cell dimensions. Can you add that information?
    – obrl_soil
    Oct 20, 2018 at 1:26
  • Are you opposed to using a programming language to get the answer?
    – TheSteve0
    Oct 20, 2018 at 2:28

1 Answer 1

7

Assuming that you use python gdal. The Geotransform object contains the coordinates of the pixel at the bottom left corner and x and y pixel size. The units are specified in the projection object that you posted. Since you have a projected reference system, you have meter units See description of your coordinate system here Once you have the Geotransform information it is easy to get to the desired pixel coordinates.

import gdal
tif = gdal.Open(my_tiff)
gt = tif.GetGeoTransform()

For example:

gt
>>>(1100000.0, 25.0, 0.0, -4200000.0, 0.0, -25.0)

We can extract the values we need:

x_min = gt[0]
x_size = gt[1]
y_min = gt[3]
y_size = gt[5]

And use them to calculate the coordinates of a given pixel:

mx, my = 500, 600  #coord in map units, as in question
px = mx * x_size + x_min #x pixel
py = my * y_size + y_min #y pixel
2
  • Is the .GetGeotransform() function should be GetGeoTransform() (capitalize T)? Mar 10, 2022 at 1:41
  • yes, thank you Nick, I have edited Mar 10, 2022 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.