フィルターのクリア

Why does projfwd not work on some geotiff files?

21 ビュー (過去 30 日間)
Ted Londner
Ted Londner 2017 年 9 月 1 日
コメント済み: Robert Drucker 2019 年 4 月 10 日
I am working with a set of geoTIFF files. For some of them, I receive an error when I attempt to use the projfwd function (see below). I have little experience with the Mapping Toolbox and geoTIFF files and would appreciate any help better understanding this problem.
Error using proj2gtif (line 17) The GeoTIFF structure PROJ cannot be used with functions PROJFWD or PROJINV.
Error in projaccess (line 40) gtif = proj2gtif(proj);
Error in projfwd (line 60) [x,y] = projaccess('fwd', proj, lat, lon);
  1 件のコメント
Reema Alhassan
Reema Alhassan 2018 年 6 月 3 日
hello if you solved this issue could you please tell me how ? because I have the same and I couldn't solve it ...
thanks

サインインしてコメントする。

採用された回答

Ted Londner
Ted Londner 2018 年 6 月 5 日
編集済み: Ted Londner 2018 年 6 月 5 日
I believe I have discovered the problem. There are multiple types of geoTIFF files, each requiring different treatment. I've written how I handled the differences below. Note that my ultimate goal was to convert latitude and longitude data into pixel coordinates, which I call 'row' and 'col'.
%Get geoTIFF file information
info = geotiffinfo(geoTIFF_filename);
%Get geoTIFF image file data based on ColorType field of 'info'
switch lower(info.ColorType)
case 'indexed'
[~, ~, R] = geotiffread(geoTIFF_filename);
otherwise
[~, R] = geotiffread(geoTIFF_filename);
end
%Convert latitude and longitude to pixel coordinates based on class of R
switch class(R)
case 'map.rasterref.GeographicCellsReference'
[row, col] = latlon2pix(R, lat, lon);
case 'map.rasterref.MapCellsReference'
[X, Y] = projfwd(info, lat, lon);
[row, col] = map2pix(R, X, Y);
otherwise
error('Unrecognized format for R');
end
  1 件のコメント
Robert Drucker
Robert Drucker 2019 年 4 月 10 日
I have been struggling with this issue, and your solution solved my problem. Thank you!!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by