Convert latitude-longitude to data grid rows and columns

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

indx = setpostn(...)

[row, col, indxPointOutsideGrid] = setpostn(...)

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

returns
the row and column indices of the regular data grid `Z`

for
the points specified by the vectors `lat`

and `lon`

. `R`

can
be a geographic raster reference object, a referencing vector, or
a referencing matrix.

If `R`

is a geographic raster reference object,
its `RasterSize`

property must be consistent with `size(Z)`

.

If `R`

is a referencing vector, it must be
1-by-3 with elements:

[cells/degree northern_latitude_limit western_longitude_limit]

`R`

is
a referencing matrix, it must be 3-by-2 and transform raster row and
column indices to/from geographic coordinates according to: [lon lat] = [row col 1] * R

`R`

is
a referencing matrix, it must define a (non-rotational, non-skewed)
relationship in which each column of the data grid falls along a meridian
and each row falls along a parallel. Points falling outside the grid
are ignored in `row`

and `col`

.
All input angles are in degrees.`indx = setpostn(...)`

returns the indices
of `Z`

corresponding to the points in `lat`

and `lon`

.
Points falling outside the grid are ignored in `indx`

.

`[row, col, indxPointOutsideGrid] = setpostn(...)`

returns
the indices of `lat`

and `lon`

corresponding
to points outside the grid. These points are ignored in `row`

and `col`

.

What are the matrix coordinates in `topo`

of
Denver, Colorado, at (39.7ºN,105ºW)?

load topo [row,col] = setpostn(topo,topolegend,39.7,105) row = 130 col = 105

Was this topic helpful?