Main Content

geotiff2mstruct

Convert GeoTIFF information to map projection structure

Syntax

mstruct = geotiff2mstruct(proj)

Description

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.

Examples

Verify that unprojecting coordinates using a GeoTIFF projection structure gives the same result as unprojecting them using a map projection structure.

To do this, first get the GeoTIFF projection structure of an image. Convert the corner map coordinates to latitude and longitude by calling projinv and specifying the GeoTIFF projection structure.

proj = geotiffinfo('boston.tif');
x = proj.CornerCoords.X;
y = proj.CornerCoords.Y;
[latProj,lonProj] = projinv(proj,x,y);

Get a map projection structure from the GeoTIFF projection structure using the geotiff2mstruct function. The length unit for map projection structures is meter, but the map coordinates are in survey feet. Therefore, convert the corner map coordinates from survey feet to meters. Then, unproject the corner coordinates by calling projinv and specifying the map projection structure.

mstruct = geotiff2mstruct(proj);
xsf = unitsratio('meter','sf') * x;
ysf = unitsratio('meter','sf') * y;
[latMstruct,lonMstruct] = projinv(mstruct,xsf,ysf);

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

Version History

Introduced before R2006a