フィルターのクリア

Create geotiff based on existing geotiff

20 ビュー (過去 30 日間)
Sam Zipper
Sam Zipper 2015 年 4 月 30 日
回答済み: Candice Liu 2017 年 6 月 15 日
Hi all-
I've got what seems like it should be a simple question (they always do...). I am attempting to read in a geotiff file, extract the spatial referencing, and use that to write a new geotiff file of the same dimensions & resolution. However, I'm having an issue transferring the georeferencing information from the geotiff I read in to the geotiff I want to write out.
% read in the existing geotiff
[img georef] = geotiffread('G:\Zipper_Landsat\StudyLC_WGS84UTM16N_NLCD2006.tif');
% create sample data you want to save as a geotiff
data = ones(size(img));
% write output as geotiff
geotiffwrite('G:\Zipper_Landsat\Test_Geotiff.tif', data, georef);
However, it returns an error:
Error using internal.map.convertToGeoRasterRef (line 39)
Function GEOTIFFWRITE expected input argument 3, 'R', to be a 3-element
referencing vector, a 3-by-2 referencing matrix, or a (scalar) geographic
raster reference object.
Error in geotiffwrite>validateR (line 842)
R = internal.map.convertToGeoRasterRef(R, rasterSize, angle_units,
...
Error in geotiffwrite>validateInputs (line 347)
R = validateR(R, size(A), hasColorMap, type);
Error in geotiffwrite (line 235)
[filename, A, cmap, R, Params] = validateInputs( ...
'georef', the georeferencing data read in from the geotiff, is a 256x3 matrix of class double. Based on the error message, it sounds like I need to convert this to some other format (a 3x2 referencing matrix, for example) - however, I can't figure out from the documentation how to transform this 256x3 to a 3x2. Does anyone have experience with this?
I am using Matlab R2014a. An alternate method to copy the georeferencing from one image to the other would also be fine, I just need to write out a geotiff!
Thanks in advance,
-Sam

回答 (1 件)

Candice Liu
Candice Liu 2017 年 6 月 15 日
Try this:
%
[img,colormap,georef]=geotiffread('......');

製品

Community Treasure Hunt

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

Start Hunting!

Translated by