| Mapping Toolbox | ![]() |
Compute row and column indices for x- and y-coordinates
Syntax
Description
[ygrat,xgrat] = rc2yx(rowgrat,colgrat,y1,x1,yperrow,xpercol) computes y- and x-coordinates from row and column indices. rowgrat and colgrat are matrices of the same size containing integer row and column indices for a grid with the upper left corner at the Cartesian coordinates x1 and y1. yperrow and xpercol are the y- and x-increments per row and column. The outputs ygrat and xgrat are the Cartesian coordinates corresponding to matrix locations rowgrat and colgrat.
Examples
[rowgrat,colgrat] = meshgrat(1:3,1:3) rowgrat = 1 1 1 2 2 2 3 3 3 colgrat = 1 2 3 1 2 3 1 2 3 x1 = -1000; y1 = 1000; yperrow = -500; xpercol = 500; [ygrat,xgrat] = rc2yx(rowgrat,colgrat,y1,x1,yperrow,xpercol) ygrat = 1000 1000 1000 500 500 500 0 0 0 xgrat = -1000 -500 0 -1000 -500 0 -1000 -500 0
Remarks
This function is used in the process of extracting projected matrix data from a file. The process generally consists of the following steps: 1) define the map projection as described in the data source documentation, 2) map desired geographic limits into projected coordinates using mfwdtran, 3) use yx2rc to determine associated row and column limits in the stored matrix, 4) extract sub-matrix using readmtx, 5) convert graticule of row and column indices to projected x and y coordinates using rc2yx, 6) convert x and y to geographic graticule using minvtran.
See Also
yx2rc |
x- and y-coordinates to row and column indices |
readmtx |
Read a matrix stored in a file |
| rad2km, rad2nm, rad2sm | rcurve | ![]() |