GeoTIFFを読み込めない

33 views (last 30 days)
Yu
Yu on 30 Sep 2021
Commented: Yu on 12 Oct 2021
こんにちは。
GeoTIFFを読み込み、地図を表示させたいのですが、エラーになってしまいます。
どうしたらよいでしょうか?
[A,R] = readgeoraster("Dynamic Surface.tif");
mapshow(A,R)

Accepted Answer

Kojiro Saito
Kojiro Saito on 30 Sep 2021
GeoTIFF画像の座標系が地理座標系か投影座標系で使う表示用の関数が変わります。
readgeorasterの第2出力(R)がMapCellsReferenceとかMapPostingsReferenceという投影座標系ではmapshowを使います。
例えばドキュメントの例にあるboston.tifは投影座標系の画像です。
[A,R] = readgeoraster('boston.tif');
whos R
Name Size Bytes Class Attributes R 1x1 16888 map.rasterref.MapCellsReference
mapshow(A,R)
一方でRが GeographicCellsReferenceGeographicPostingsReferenceの場合はgeoshowで可視化できます。
[A2,R2] = readgeoraster('n39_w106_3arc_v2.dt1','OutputType','double');
whos R2
Name Size Bytes Class Attributes R2 1x1 1848 map.rasterref.GeographicPostingsReference
latlim = R2.LatitudeLimits;
lonlim = R2.LongitudeLimits;
figure
usamap(latlim,lonlim)
geoshow(A2,R2,'DisplayType','surface')
demcmap(A2)
mapshowで出ているエラーから推測すると、お使いのデータの座標系(R)がMap**の投影座標系になっていないと思われます。
Geographic**の座標系になっていたら、geoshowをお使いになってはいかがでしょうか。
  11 Comments
Kojiro Saito
Kojiro Saito on 11 Oct 2021
添付ありがとうございます。
A(:, :, 4)は0か255の2値になっていて、ピクセルの輝度値が画像の領域内なら255、領域外なら0になっているだけでしたね。
A(:, :, 1:3)の色情報を緯度、経度にマッピングするには不要の情報でした。
[A, R] = readgeoraster("Sample.tif");
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lat,lon] = projinv(p,x,y);
geoshow(lat,lon, A(:,:,1:3))
geoshowの中に緯度経度座標に投影したAの色情報(1:3)だけ入れればできました。
Yu
Yu on 12 Oct 2021
なるほど、輝度値というのがあるのですね。勉強になりました。
こちらでも、元のデータで無事緯度経度に変換できました。
何度も丁寧にお答えいただき大変助かりました!ありがとうございました。

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!