matlab geotiffwrite,Write GeoTIFF file
Create Raw RPC Coefficient Metadata
To simulate raw RPC metadata, create a simple test file and write some RPC metadata to the file. For this test file, create a toy image and a referencing object associated with the image.
myimage = zeros(180,360);
latlim = [-90 90];
lonlim = [-180 180];
R = georefcells(latlim,lonlim,size(myimage));
Create an RPCCoefficientTag metadata object and set some of the fields. The toolbox uses the RPCCoefficientTag object to represent RPC metadata in human readable form.
rpctag = map.geotiff.RPCCoefficientTag;
rpctag.LineOffset = 1;
rpctag.SampleOffset = 1;
rpctag.LineScale = 2;
rpctag.SampleScale = 2;
rpctag.GeodeticHeightScale = 500;
Write the image, the associated referencing object, and the RPCCoefficientTag object to a file.
geotiffwrite('myfile',myimage,R,'RPCCoefficientTag',rpctag)
Read Raw RPC Coefficient Metadata
Read the RPC coefficient metadata from the test file using the imfinfo function. When it encounters unfamiliar metadata, imfinfo returns the data, unprocessed, in the UnknownTags field. Note that the UnknownTags field contains an array of 92 doubles. This is the raw RPC coefficient metadata, read from the file in unprocessed form.
info = imfinfo('myfile.tif');
info.UnknownTags
ans = struct with fields:
ID: 50844
Offset: 10676
Value: [1x92 double]
Write Raw RPC Metadata to a File
Write the raw RPC metadata to a file. First, extract the RPC coefficient metadata from the info structure.
value = info.UnknownTags.Value;
Then, construct an RPCCoefficientTag object, passing the raw RPC metadata (array of 92 doubles) as an argument.
rpcdata = map.geotiff.RPCCoefficientTag(value)
rpcdata =
RPCCoefficientTag with properties:
BiasErrorInMeters: -1
RandomErrorInMeters: -1
LineOffset: 1
SampleOffset: 1
GeodeticLatitudeOffset: 0
GeodeticLongitudeOffset: 0
GeodeticHeightOffset: 0
LineScale: 2
SampleScale: 2
GeodeticLatitudeScale: 1
GeodeticLongitudeScale: 1
GeodeticHeightScale: 500
LineNumeratorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
LineDenominatorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
SampleNumeratorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
SampleDenominatorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
Pass the RPCCoefficientTag object to the geotiffwrite function and write the RPC metadata to a file.
geotiffwrite('myfile2',myimage,R,'RPCCoefficientTag',rpcdata)
To verify that the data was written to the file, read the RPC metadata from the TIFF file using geotiffinfo. Compare the returned RPC metadata with the metadata written to the test file.
ginfo = geotiffinfo('myfile2');
ginfo.GeoTIFFTags.RPCCoefficientTag
ans =
RPCCoefficientTag with properties:
BiasErrorInMeters: -1
RandomErrorInMeters: -1
LineOffset: 1
SampleOffset: 1
GeodeticLatitudeOffset: 0
GeodeticLongitudeOffset: 0
GeodeticHeightOffset: 0
LineScale: 2
SampleScale: 2
GeodeticLatitudeScale: 1
GeodeticLongitudeScale: 1
GeodeticHeightScale: 500
LineNumeratorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
LineDenominatorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
SampleNumeratorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
SampleDenominatorCoefficients: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)