
画像,figureを地図上にプロットする方法
21 views (last 30 days)
Show older comments
Takaki Fujii
on 16 Jan 2019
Edited: Shunichi Kusano
on 17 Jan 2019
添付の画像のように、地図上の任意の位置に画像(コンター)をプロットする方法を教えてください。
極座標表示のコンターを緯度経度で決まるグリッドにプロットしています。
このコンターをどのように扱っているの分かりません。(画像をプロットしているのか、出力をそのまま地図上にプロットするのか)
任意の緯度経度での出力を画像として保存し、それを読み込んで、緯度経度に対応する行列にプロットするといったようにやろうとしましたがうまくいきませんでした。
よろしくお願いいたします。

0 Comments
Accepted Answer
Shunichi Kusano
on 17 Jan 2019
Edited: Shunichi Kusano
on 17 Jan 2019
地図上に、とのことですので、Mapping toolboxをお持ちの前提で回答いたします。
またgeoshowでの各画素に対しての、alphaの設定には2015b以降のバージョンが必要となるようです。
もっとスマートな手順があるかとは思いますが、とりいそぎ、次の手順でご所望の図を出力可能です。
極座標プロットの準備
% ダミー画像の作成
theta = 0:0.01:2*pi;
rho = sin(3*theta).*cos(2*theta);
fig = figure('Position',[0 0 400 400]); % サイズを正方に
polarplot(theta, rho, 'LineWidth', 6);
ax = gca;
ax.LineWidth = 6;
ax.Color = [0.99, 0.99, 0.99]; % 後で余白を透明にする。透明にする画素を[255 255 255]としたいため、グラフ内の背景色を変更
set(gcf, 'Color', [1,1,1]); % 余白領域を白色に->後で透明とする
%fig.Color = [0.99 0.01 0.01];
thetaticklabels([]);
set(gca, 'LooseInset', get(gca, 'TightInset')); % 余分な余白を削る
fig.InvertHardcopy = 'off'; % 保存時に設定した色が有効となるよう設定
saveas(gcf, 'your_polar.png');
背景地図の表示
states = geoshape(shaperead('usastatehi', 'UseGeoCoords', true));
figure, hold on;
worldmap('na'); % 地図領域の描画
%oceanColor = [.5 .7 .9];
geoshow(states); % アメリカの領土の描画
極座標プロット画像の読み込み
img = imread('your_polar.png');
% figure, imshow(img)
% 座標の定義
latLen = 10; % 重ねる画像の大きさ(緯度方向:経度に合わせて後でスケール)
lonLen = 10; % 重ねる画像の大きさ(経度方向)
latNum = size(img,1); % 重ねる画像の画素数(緯度方向)
lonNum = size(img,2); % 重ねる画像の画素数(経度方向)
latCors = linspace(0,-latLen,latNum)+latLen/2; % 画像の座標に相当する緯度ベクトルの生成
lonCors = linspace(0,lonLen,lonNum)-lonLen/2; % 画像の座標に相当する経度ベクトルの生成
[latCors, lonCors] = meshgrid(latCors,lonCors); % 行列化
alphamat = all(img == 255, 3); % アルファ値の設定 % 透過にする画素のマスク
画像の挿入
for latCenter = 30:20:70; % 画像の中心緯度座標
for lonCenter = -150:20:-90; % 画像の中心経度座標
r = (90-latCenter) / (90-30); % 経度のスケールに合わせるための倍率
geoimg = geoshow(r*latCors+latCenter, lonCors+lonCenter, permute(img,[2 1 3]), 'DisplayType', 'texturemap');% Center座標を画像中心として重ねる
geoimg.AlphaDataMapping = 'none';
geoimg.FaceAlpha = 'texturemap';
alpha(geoimg, double(~alphamat)); % 透過
end
end

0 Comments
More Answers (0)
See Also
Categories
Find more on Vector and Raster Map Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!