필터 지우기
필터 지우기

Hi i created a matfile of hourly temperature 334*334*2928 . how i can convert the .mat file to Tif file ?

조회 수: 32 (최근 30일)
attached the screen shot
  댓글 수: 2
Umar
Umar 2024년 7월 19일 6:20

Hi Vineetha,

To convert a .mat file to a TIF file in Matlab, you can use the following steps:

% Load the .mat file

load('hourly_temperature_data.mat');

% Reshape the data to a 3D matrix

temperature_data = reshape(hourly_temperature_data, [334, 334, 2928]);

% Loop through each slice and save as TIF

for i = 1:2928

    imwrite(temperature_data(:,:,i), ['temperature_slice_', num2str(i), '.tif']);
end

So, you load the .mat file, reshape the data to a 3D matrix, and then loop through each slice to save it as a TIF file. Each slice will be saved as a separate TIF file with a unique name. Hope this should help resolve your problem.

vineetha vincent
vineetha vincent 2024년 7월 19일 6:34
Hi Umar,
Thanks for the suggestion . The converted Tif files, i couldnt able to open in Arcgis pro .

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2024년 7월 19일 6:19
I suggest using the Mapping Toolbox, geotiffwrite
  댓글 수: 3
Umar
Umar 2024년 7월 19일 8:10
Hi Walter,
Thanks for your contribution. Please correct me if I am wrong, it is preferable to use geotiffwrite instead of imwrite in Matlab because geotiffwrite allows you to write GeoTIFF files which contains georeferencing information essential for GIS applications so ArcGIS Pro can correctly interpret the spatial data.
Walter Roberson
Walter Roberson 2024년 7월 19일 18:12
geotiffwrite() knows how to automatically take care of multiple bit planes.
In theory you can do the same thing by using the Tiff library, but you need to know how to handle the extra bit planes and need to know what tags to use.
One thing I just realized is that your data is double(). geotiffwrite() handles that internally. imwrite() converts double to uint8 if I recall correctly. To write double precision tiff images you need to use geotiffwrite() or you need to use the Tiff interface (there is, by the way, a file exchange contribution that correctly handles double precision tiff.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by