1

I have a GeoTIFF file and with gdalinfo command I found the following info:

Size is 1200, 1400
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",42],
    PARAMETER["central_meridian",12.5],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (-598884.437500000000000,650790.250000000000000)
Pixel Size = (996.479919433593750,-999.677795410156250)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2018:04:01 00:10:06
  TIFFTAG_DOCUMENTNAME=/datamet/data/tmp/export/RADAR/36/RRN/VMI/VMI.geotif
  TIFFTAG_IMAGEDESCRIPTION=IDL TIFF file
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=IDL 8.3, Exelis Visual Information Solutions, Inc.
  TIFFTAG_XRESOLUTION=100
  TIFFTAG_YRESOLUTION=100
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( -598884.438,  650790.250) (  4d32'13.20"E, 47d34'44.14"N)
Lower Left  ( -598884.438, -748758.664) (  5d56'18.16"E, 35d 4'36.70"N)
Upper Right (  596891.466,  650790.250) ( 20d26'12.34"E, 47d34'50.73"N)
Lower Right (  596891.466, -748758.664) ( 19d 2'23.69"E, 35d 4'40.94"N)
Center      (    -996.486,  -48984.207) ( 12d29'17.00"E, 41d33'32.31"N)
Band 1 Block=1200x1 Type=Float32, ColorInterp=Gray

Can you tell me a possible algorithm to associate a pair of lat/long coordinates to each point of the grid?

2
  • Please be more precise to what you expect as result. Do you want a raster back or a table with one line per pixel (so 1200x1400 lines) and x,y,lat/lon columns ? It will guide the kind of answer we can give you.
    – Billy34
    Commented Apr 11, 2018 at 14:52
  • I want a 1200 x 1400 size matrix with: matrix [x] [y] --> double [] {lon, lat} Commented Apr 11, 2018 at 15:47

1 Answer 1

1

For each pixel of the GeoTIFF file you can compute the corresponding projected coordinates using Origin and Pixel Size. Then, project back from Mercator to WGS84 using OGR or PROJ4.

To compute the projected coordinates you simply have to add the Origin and scale according to Pixel Size.

Say Px, Py are pixels coordinates and PrjX, PrjY are the corresponding Mercator coordinates you can do:

PrjX = OriginX + Px * SizeX
PrjY = OriginY + Py * SizeY

However, if you are programming using GDAL you can use the built in GeoTransform matrix to obtain the relationship between raster positions and projected coordinates.

Your Answer

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

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