Main Content

# latlon2pix

(Removed) Convert latitude-longitude coordinates to pixel coordinates

The `latlon2pix` function has been removed. Use the `geographicToIntrinsic` function instead. For more information, see Version History.

## Syntax

```[row, col ] = latlon2pix(R,lat,lon) ```

## Description

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

Longitude wrapping is handled in the following way: Results are invariant under the substitution `lon = lon +/- n * 360` where `n` is an integer. Any point on the Earth that is included in the image or gridded data set corresponding to `r` will yield row/column values between 0.5 and 0.5 + the image height/width, regardless of what longitude convention is used.

## Examples

Find the pixel coordinates of the upper left and lower right outer corners of a 2-by-2 degree gridded data set.

```R = georefcells([-90 90],[0 360],2,2,'ColumnsStartFrom','north') [UL_row, UL_col] = latlon2pix(R, 90, 0) % Upper left [LR_row, LR_col] = latlon2pix(R, -90, 360) % Lower right```

## Version History

Introduced before R2006a

expand all

### R2024b: Removed

Some functions that accept referencing matrices as input have been removed, including the `latlon2pix` function. Use a geographic raster reference object and the `geographicToIntrinsic` 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 `latlon2pix` function with the `geographicToIntrinsic` function according to this pattern.

RemovedRecommended
`[row,col] = latlon2pix(R,lat,lon);`
`[col,row] = geographicToIntrinsic(R,lat,lon)`