Main Content

worldFileMatrix

Return world file parameters for transformation

Description

example

W = worldFileMatrix(R) returns a 2-by-3 world file matrix from geographic or map raster R.

Examples

collapse all

Create a MapCellsReference raster reference object.

xWorldLimits = [207000 208000];
yWorldLimits = [912500 913000];
rasterSize = [10 20];
R = maprefcells(xWorldLimits,yWorldLimits,rasterSize,'ColumnsStartFrom','north')
R = 
  MapCellsReference with properties:

            XWorldLimits: [207000 208000]
            YWorldLimits: [912500 913000]
              RasterSize: [10 20]
    RasterInterpretation: 'cells'
        ColumnsStartFrom: 'north'
           RowsStartFrom: 'west'
      CellExtentInWorldX: 50
      CellExtentInWorldY: 50
    RasterExtentInWorldX: 1000
    RasterExtentInWorldY: 500
        XIntrinsicLimits: [0.5 20.5]
        YIntrinsicLimits: [0.5 10.5]
      TransformationType: 'rectilinear'
    CoordinateSystemType: 'planar'
            ProjectedCRS: []


Compute the world file matrix.

W = worldFileMatrix(R)
W = 2×3

          50           0      207025
           0         -50      912975

Observe that W(2,1) and W(1,2) are 0. This value is expected since R.TransformationType is 'rectilinear'.

Input Arguments

collapse all

Geographic or map raster, specified as a GeographicCellsReference, GeographicPostingsReference, MapCellsReference, or MapPostingsReference object.

Output Arguments

collapse all

World file matrix, returned as a 2-by-3 numeric array. Each of the six elements in W matches one of the lines in a world file corresponding to the transformation defined by raster referencing object R.

Data Types: double

More About

collapse all

World File Matrix

A world file matrix maps points in intrinsic coordinates to points in geographic or planar world coordinates.

Given a world file matrix W of the form:

W = [A B C;
     D E F]
a point ( xi, yi ) maps to a point ( xw, yw ) in world coordinates according to:

xw = A × ( xi - 1 ) + B × ( yi - 1 ) + C

yw = D × ( xi - 1 ) + E × ( yi - 1 ) + F.

More compactly:

[ xw yw ]′ = W × [ ( xi - 1 ) ( yi - 1 ) ].

Note

Similar equations hold true for points ( lat, lon ) in geographic coordinates. However, the geographic coordinate ordering is switched. That is, xw is substituted by lon, and yw is substituted by lat.

The −1s are needed to maintain the Mapping Toolbox™ convention for intrinsic coordinates, which is consistent with the 1-based indexing used throughout MATLAB®.

W is stored in a world file with one term per line in column-major order: A, D, B, E, C, F. That is, a world file contains the elements of W in this order:

W(1,1)
W(2,1)
W(1,2)
W(2,2)
W(1,3)
W(2,3)

The previous expressions hold for both affine and rectilinear transformations of rasters. The values B, D, W(2,1) and W(1,2) are identically 0 whenever:

  • R is a geographic raster, since longitude depends only on intrinsic x and latitude depends only on intrinsic y

  • R is a map raster and R.TransformationType is 'rectilinear'

Version History

Introduced in R2013b