Convert GeoTIFF information to map projection structure


mstruct = geotiff2mstruct(proj)


mstruct = geotiff2mstruct(proj) converts the GeoTIFF projection structure, proj, to the map projection structure, mstruct. The unit of length of the mstruct projection is meter.

The GeoTIFF projection structure, proj, must reference a projected coordinate system, as indicated by a value of 'ModelTypeProjected' in the ModelType field. If ModelType has the value 'ModelTypeGeographic' then it doesn't make sense to convert to a map projection structure and an error is issued.


% Compare inverse transform of points using projinv and minvtran.
% Obtain the projection structure of 'boston.tif'.
proj = geotiffinfo('boston.tif');

% Convert the corner map coordinates to latitude and longitude.
x = proj.CornerCoords.X;
y = proj.CornerCoords.Y;
[latProj, lonProj] = projinv(proj, x, y);

% Obtain the mstruct from the GeoTIFF projection.
mstruct = geotiff2mstruct(proj);

% Convert the units of x and y to meter to match projection units.
x = unitsratio('meter','sf') * x;
y = unitsratio('meter','sf') * y;

% Convert the corner map coordinates to latitude and longitude.
[latMstruct, lonMstruct] = minvtran(mstruct, x, y);

% Verify the values are within a tolerance of each other.
abs(latProj - latMstruct) <= 1e-7
abs(lonProj - lonMstruct) <= 1e-7

ans =
     1     1     1     1

ans =
     1     1     1     1

Introduced before R2006a