【问题标题】:Creating a geoTIFF from an image in Matlab在 Matlab 中从图像创建 geoTIFF
【发布时间】:2017-09-06 16:36:32
【问题描述】:

我正在尝试从附加的 png 在 Matlab 中创建一个 geoTIFF 文件。 example image 我正在遵循以下提供的示例: https://uk.mathworks.com/help/map/examples/exporting-images-and-raster-grids-to-geotiff.html

但需要从头开始创建地理配准信息,因此使用 makerefmat 和 worldfilewrite 来实现这一点。下面的代码不会导致崩溃,但会生成一个图像阅读器似乎很难处理的 TIFF,所以我认为我做错了什么。由于我以前没有使用过 TIFF 标签,因此也可能存在一些冗余。任何帮助表示赞赏!

% Load image without georeferencing
RGB = imread('uk_dT.png');

% Create worldfile for image.  At present this is done by first creating a
% reference matrix, then using these values to generate a worldfile.
% Longitude spans -17:10 (west to east), latitude 63:47 (north to south)
lonmin = -17; lonmax = 10; latmin = 47; latmax = 63;
DX = (lonmax-lonmin)/(length(RGB(1,:,1))); DY = (latmin-latmax)/(length(RGB(:,1,1)));
R = makerefmat(lonmin, latmax, DX, DY);
worldfilewrite(R,'uk_dT.tfw');

% Read worldfile, create geotiff
REF = worldfileread('uk_dT.tfw','geographic',size(RGB));
geotiffwrite('uk_dT.tif',RGB,REF)

【问题讨论】:

    标签: matlab geotiff


    【解决方案1】:

    出于兴趣,我在另一个论坛上改进了这段代码。结果仍然无法在某些图像查看器中打开,但我认为这与数据的类别有关。当我为 GIS 软件写作时,这个解决方案对我有用。

    file = 'uk_dT.png' ; 
    [path,name,ext] = fileparts(file) ;
    
    I = imread(file) ;
    lonmin = -17; lonmax = 10; latmin = 47; latmax = 63;
    
    % Write to geotiff
    R = georasterref('RasterSize',size(I),'LatitudeLimits', [latmin,latmax],'LongitudeLimits',[lonmin,lonmax]);
    tiffile = strcat(name,'.tif') ;
    geotiffwrite(tiffile,I,R)
    

    【讨论】:

      猜你喜欢
      • 2018-02-08
      • 1970-01-01
      • 2015-03-07
      • 1970-01-01
      • 2013-05-31
      • 2018-05-21
      • 2013-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多