# neworig

Orient regular data grid to oblique aspect

## Syntax

```[Z,lat,lon] = neworig(Z0,R,origin) [Z,lat,lon] = neworig(Z0,R,origin,'forward') [Z,lat,lon] = neworig(Z0,R,origin,'inverse') ```

## Description

`[Z,lat,lon] = neworig(Z0,R,origin)` and ```[Z,lat,lon] = neworig(Z0,R,origin,'forward')``` will transform regular data grid `Z0` into an oblique aspect, while preserving the matrix storage format. In other words, the oblique map origin is not necessarily at (0,0) in the Greenwich coordinate frame. This allows operations to be performed on the matrix representing the oblique map. For example, azimuthal calculations for a point in a data grid become row and column operations if the data grid is transformed so that the north pole of the oblique map represents the desired point on the globe.

`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 a 1-by-3 with elements:

`[cells/degree northern_latitude_limit western_longitude_limit]`

If `R` is a referencing matrix, it must be 3-by-2 and transform raster row and column indices to or from geographic coordinates according to:

`[lon lat] = [row col 1] * R`

If `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. Nearest-neighbor interpolation is used by default. NaN is returned for points outside the grid limits or for which `lat` or `lon` contain NaN. All angles are in units of degrees.

`[Z,lat,lon] = neworig(Z0,R,origin,'inverse')` transforms the regular data grid from the oblique frame to the Greenwich coordinate frame.

The `neworig` function transforms a regular data grid into a new matrix in an altered coordinate system. An analytical use of the new matrix can be realized in conjunction with the `newpole` function. If a selected point is made the north pole of the new system, then when a new matrix is created with `neworig`, each row of the new matrix is a constant distance from the selected point, and each column is a constant azimuth from that point.

## Limitations

`neworig` only supports data grids that cover the entire globe.

## Examples

Load elevation raster data and a geographic cells reference object. Then, transform the map so that Sri Lanka is at the North Pole.

```load topo60c origin = newpole(7,80); Z = neworig(topo60c,topo60cR,origin); axesm miller gridm on lat = linspace(-90,90,90); lon = linspace(-180,180,180); surfm(lat,lon,Z) demcmap(topo60c) tightmap```

## Version History

Introduced before R2006a