#author("2020-11-14T01:10:25+09:00","default:Miyashita","Miyashita")
#author("2020-11-16T12:20:10+09:00","default:Miyashita","Miyashita")
*海岸線を引く,陸地部分に色付けする [#m476a41d]
GMT の pscoast みたいなことを GMT や M_MAP に頼らず MATLAB でもやりたい.~
~

**海岸線データ取得 [#g8c0d6dc]
GSHHG のデータを使わせてもらう.~
Mapping Toolbox が入っていると最初に一番粗いデータだけ入っているはず.
 $ locate gshhs_c.b.gz
 /usr/local/src/MATLAB/R2019b/toolbox/map/mapdata/gshhs_c.b.gz
さらに細かい解像度が必要な場合は [[NOAA のここ>https://www.ngdc.noaa.gov/mgg/shorelines/data/gshhg/latest/]] から拾ってくる.~
gshhg-bin-X.X.X.zip に gshhs_c.b や gshhs_h.b などが入っており,拡張子の前の1文字は解像度を指す.~
GMT の pscoast と同じで,粗い順に c (crude), l (low), i (intermediate), h (high), f (full).~
~
~

**GSHHG と Mapping Toolbox を使って境界を描く,境界面を塗る [#e867a2ae]
GSHHG のファイルから都合の良い領域のデータを切り出す.~
gshhs コマンドを使って取得したデータは構造体になっている.~
単に海岸線だけがほしい(河川の境界はいらない等の)場合には,Level が 1 になっているものを抜き出して描く.~
#codeprettify(lang-matlab){{
LatLim = [20,50];
LonLim = [120,155];
S = gshhs('./gshhs_i.b', LatLim, LonLim);
S = S([S.Level]==1);
}}
#codeprettify(lang-matlab){{
figure
axis off
axm = axesm('eqdconic', 'FLineWidth', 1.0, 'MapLonLimit', LonLim, 'MapLatLimit', LatLim);
geoshow(S, 'EdgeColor', 'k','FaceColor',[1.0, 1.0, 0.5])
gridm on
framem on
mlabel
plabel
mlabel on
plabel on
axesm(getm(axm),'LabelRotation','on','PLabelLocation',10,'MlabelLocation',10,'PLineLocation',5,'MLineLocation',5)
}}
色は EdgeColor と FaceColor の値を変えれば海岸線・陸地の色が変えられる.~
もちろんどちらかを描かないこともできる.~

#ref(https://main-t-miyashita.ssl-lolipop.jp/hydrocoast/image/MATLAB/test_gshhs.png,583x437)
~

**参考 [#d75238d2]
MathWorks のページ.~
-[[gshhs>https://jp.mathworks.com/help//map/ref/gshhs.html]]
-[[Converting Coastline Data (GSHHG) to Shapefile Format>https://jp.mathworks.com/help//map/converting-coastline-data-gshhs-to-shapefile-format.html]]

Front page   Edit Diff Attach Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes