Skip to content

Instantly share code, notes, and snippets.

@komasaru
Created April 28, 2016 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komasaru/059258df6e290e8fde12ef989f4c3221 to your computer and use it in GitHub Desktop.
Save komasaru/059258df6e290e8fde12ef989f4c3221 to your computer and use it in GitHub Desktop.
Bash script to paint a Japan's elevetion map by GMT(Mercator).
#! /bin/bash
# 各種定数
GRD_PATH=/path/to/ETOPO1_Bed_g_gmt4.grd
IMG_DIR=imgs
IMG_FILE=JAPAN_ETOPO1
T=-10000/10000/100
R=122/148/23/47
J=M12c
E=100
B=a5f5g5
D=9c/-1c/5c/0.5ch
F=+j+a+f12p,Helvetica,black
# 用紙サイズ
gmtset PS_MEDIA = Custom_15cx17c
# 範囲抽出
grdcut $GRD_PATH -R$R -G${IMG_FILE}.grd
# 配色設定
makecpt -Cglobe -T$T -Z > ${IMG_FILE}.cpt
# 陰影データ作成
grdgradient $IMG_FILE.grd -A270 -G${IMG_FILE}.int -Ne0.7
# 図描画
grdimage ${IMG_FILE}.grd -I${IMG_FILE}.int -R -J$J -C${IMG_FILE}.cpt -E$E -X1.5 -Y2.5 -P -K > ${IMG_DIR}/${IMG_FILE}.ps
# 海岸線描画
pscoast -R -J -Dh -W,darkgreen -O -K >> ${IMG_DIR}/${IMG_FILE}.ps
# 縦軸・横軸描画
psbasemap -R -J -B$B -O -K >> ${IMG_DIR}/${IMG_FILE}.ps
# コピーライト描画
echo "132 36 BL 0.0 (c)mk-mode.com" | pstext -R -J -F$F -O -K >> ${IMG_DIR}/${IMG_FILE}.ps
# 凡例描画
psscale -Ba4000g2000f1000 -C${IMG_FILE}.cpt -D$D -O >> ${IMG_DIR}/${IMG_FILE}.ps
# ps -> png
ps2raster ${IMG_DIR}/${IMG_FILE}.ps -Tg -Qt -Qg -E$E
# ps -> jpg
#ps2raster ${IMG_DIR}/${IMG_FILE}.ps -Qt -Qg -E$E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment