Draping an image over topography
# Here we get and convert the flag of Europe directly from the web through grdconvert using
# GDAL support. We take into account the dimension of the flag (1000x667 pixels)
# for a ratio of 3x2.
# gmt grdconvert \
# http://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Flag_of_Europe.svg/1000px-Flag_of_Europe.svg.png=gd \
# euflag.nc=ns
# gmt grdedit euflag.nc -fg $Rflag
# Now get the topography for the same area from GTOPO30 and store it as@topo_32.nc.
# The DEM file comes from http://eros.usgs.gov/#/Find_Data/Products_and_Data_Available/gtopo30/w020n90
# We make a gradient grid as well, which we will use to "illuminate" the flag.
# gmt grdcut W020N90.DEM $Rflag -Gtopo_32.nc=ns
# The color map assigns "Reflex Blue" to the lower half of the 0-255 range and
# "Yellow" to the upper half.
makecpt(color=[0 51 153; 255 204 0], range="0,127,255", nobg=true)
grdview("@topo_32.nc", region=[3 9 50 54 10 790], proj=:merc, figsize=13, drapefile="@euflag.nc", shade=(azim=(0, 270), norm="e0.6"), surftype=(nan_alpha=true,), zsize=1, frame=:none, view=(157.5, 30))
# We now add borders. Because we have a 3-D plot, we want them to be plotted "at elevation".
# So we write out the borders, pipe them through grdtack and then plot them with psxyz.
t = coast!(res=:full, dump=true, borders=1);
t = grdtrack("@topo_32.nc", t, skip_NaN=:a);
plot3d!(t, JZ=1, pen=(1,:white))
# Finally, we add dots and names for three cities.
# Again, gmt grdtrack is used to put the dots "at elevation".
fid = open("cities.txt", "w")
println(fid, "05:41:27 50:51:05 Maastricht")
println(fid, "04:21:00 50:51:00 Bruxelles")
println(fid, "07:07:03 50:43:09 Bonn")
close(fid)
t = grdtrack("@topo_32.nc", "cities.txt")
plot3d!(t, JZ="", marker=:circle, ms="7p", ml=(1,:white), fill=:red)
text!("cities.txt", font=(12,"Helvetica-Bold",:red), justify=:RM, offset=(away=true, shift=(0.25, 0)), show=true)
rm("cities.txt");
See also GMT ex32