2017-09-06 22 views
1

첨부 된 png에서 Matlab에서 geoTIFF 파일을 만들려고합니다. 그래서이 acheive하는 makerefmat 및 worldfilewrite를 사용하여, https://uk.mathworks.com/help/map/examples/exporting-images-and-raster-grids-to-geotiff.htmlMatlab의 이미지에서 geoTIFF 만들기

하지만 처음부터 정보를 지리 참조 연산 만들어야합니다 example image 나는에서 제공하는 예를 다음과 같은거야. 아래의 코드는 충돌을 일으키지 않지만 TIFF를 생성합니다. 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) 

답변

0

관심 분야로,이 코드는 다른 포럼에서 나에게 개선되었습니다. 일부 이미지 뷰어에서는 여전히 결과가 열리지 않지만 데이터 클래스와 관련이 있다고 생각합니다. 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)