Main Content


(To be removed) Convert pixel coordinates to latitude-longitude coordinates

The pix2latlon function will be removed in a future release. Use the intrinsicToGeographic function instead. For more information, see Compatibility Considerations.


[lat, lon] = pix2latlon(R,row,col)


[lat, lon] = pix2latlon(R,row,col) calculates latitude-longitude coordinates lat, lon from pixel coordinates row, col. R is either a 3-by-2 referencing matrix that transforms intrinsic pixel coordinates to geographic coordinates, or a geographic raster reference object. row and col are vectors or arrays of matching size. The outputs lat and lon have the same size as row and col.


Find the latitude and longitude of the upper left outer corner of a gridded data set.

load korea5c
[UL_lat,UL_lon] = pix2latlon(korea5cR,0.5,0.5)

The output appears as follows:

UL_lat =


UL_lon =


Version History

Introduced before R2006a

expand all

R2023a: Warns

Some functions that accept referencing matrices as input issue a warning that they will be removed in a future release, including the pix2latlon function. Use a geographic raster reference object and the intrinsicToGeographic function instead. Reference objects have several advantages over referencing matrices.

  • Unlike referencing matrices, reference objects have properties that document the size of the associated raster, its geographic limits, and the direction of its rows and columns. For more information about reference object properties, see the GeographicCellsReference and GeographicPostingsReference objects.

  • You can manipulate the limits of rasters associated with reference objects using the geocrop function.

  • You can manipulate the size and resolution of rasters associated with reference objects using the georesize function.

  • Most functions that accept referencing matrices as inputs also accept reference objects.

To update your code, first create a reference object for either a raster of cells using the georefcells function or a raster of regularly posted samples using the georefpostings function. Alternatively, convert from a referencing matrix to a reference object using the refmatToGeoRasterReference function.

Then, replace uses of the pix2latlon function with the intrinsicToGeographic function according to this pattern.

Will Be RemovedRecommended
[lat,lon] = pix2latlon(R,row,col);
[lat,lon] = intrinsicToGeographic(R,col,row);