geotiff2mstruct
Convert GeoTIFF information structure to map projection structure
Description
Examples
Get information about a GeoTIFF file by using the geotiffinfo
function. The file contains an image of Boston that is referenced to projected coordinates. The function stores the information in a structure array.
proj = geotiffinfo("boston.tif");
Convert the GeoTIFF information structure to a map projection structure by using the geotiff2mstruct
function.
mstruct = geotiff2mstruct(proj);
Read an overview image of Boston into the workspace as an array and a raster reference object. The overview image is referenced to geographic coordinates.
A = imread("boston_ovr.jpg"); R = worldfileread("boston_ovr.jgw","geographic",size(A));
Create an axesm
-based map using the projection stored in the map projection structure. Specify the geographic limits of the map using the limits stored in the reference object. Customize the map by adding labels and graticule lines.
figure latlim = R.LatitudeLimits; lonlim = R.LongitudeLimits; axesm(mstruct,MapLatlimit=latlim,MapLonlimit=lonlim, ... Grid="on",GColor=[0.9 0.9 0.9], ... ParallelLabel="on",PLabelLocation=0.025,PLabelRound=-2, ... PLineLocation=0.025, ... MeridianLabel="on",MLabelLocation=0.025,MLabelRound=-2, ... MLineLocation=0.025) tightmap
Display the overview image on the map. The geoshow
function projects the geographic coordinates using the map projection structure.
geoshow(A,R,DisplayType="image")
Get information about a GeoTIFF file by using the geotiffinfo
function. The function stores the information in a structure array.
proj = geotiffinfo("boston.tif");
Convert the GeoTIFF information structure to a map projection structure by using the geotiff2mstruct
function.
mstruct = geotiff2mstruct(proj);
Compare the projection stored in the GeoTIFF file to the map projection structure by unprojecting coordinates.
Specify xy-coordinates using the corner coordinates stored in the GeoTIFF file.
x = proj.CornerCoords.X; y = proj.CornerCoords.Y;
Get the length unit from the map projection structure. The length unit is survey feet.
unit = proj.UOMLength
unit = 'US survey foot'
Convert the corner coordinates from survey feet to meters. You must perform this step because the geotiff2mstruct
function reports linear values using meters.
xsf = unitsratio("meter","sf") * x; ysf = unitsratio("meter","sf") * y;
Unproject the coordinates using the GeoTIFF information structure and the map projection structure. Then, verify that the values are equal.
[latProj,lonProj] = projinv(proj,x,y); [latMstruct,lonMstruct] = projinv(mstruct,xsf,ysf); isequal(latProj,latMstruct)
ans = logical
1
isequal(lonProj,lonMstruct)
ans = logical
1
Input Arguments
GeoTIFF information structure, specified as a structure array returned by the
geotiffinfo
function. The
ModelType
field of the structure array must have a value of
'ModelTypeProjected'
.
Output Arguments
Map projection structure, returned as a structure array with fields identical to the
properties of an axesm
-based map. For more information about the
properties of axesm
-based maps, see axesm-Based Map Properties. The map projection structure returned by the
geotiff2mstruct
function reports linear values using
meters.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)