|
8 | 8 | This tutorial consists of two examples: |
9 | 9 |
|
10 | 10 | 1. Draping a grid |
11 | | -
|
12 | 11 | 2. Draping an image |
13 | 12 | """ |
14 | 13 |
|
|
53 | 52 | pygmt.makecpt(cmap="SCM/batlow", series=[0, 200, 1], reverse=True, overrule_bg=True) |
54 | 53 |
|
55 | 54 | fig.grdview( |
56 | | - projection="M12c", # Mercator projection with a width of 12 centimeters |
| 55 | + projection="M12c", # Mercator projection with a width of 12 cm |
57 | 56 | region=region_3d, |
58 | 57 | grid=grd_relief, # Use elevation grid for z values |
59 | 58 | drape_grid=grd_age, # Use crustal age grid for color-coding |
|
96 | 95 | # Determine the 3-D region from the minimum and maximum values of the relief grid |
97 | 96 | region_3d = [*region_2d, grd_relief.min().to_numpy(), grd_relief.max().to_numpy()] |
98 | 97 |
|
99 | | -# Download an PNG image of the flag of the EU using rasterio and load it into a |
100 | | -# xarray.DataArray |
101 | | -url_to_image = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Flag_of_Europe.svg/1024px-Flag_of_Europe.svg.png" |
| 98 | +# Load a PNG image of the EU flag using rasterio into an xarray.DataArray. |
| 99 | +# The original image is available on Wikimedia Commons at |
| 100 | +# https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Flag_of_Europe.svg/1024px-Flag_of_Europe.svg.png |
| 101 | +# but we use a cached version on the GMT data server. |
| 102 | +url_to_image = "https://oceania.generic-mapping-tools.org/cache/euflag.png" |
102 | 103 | with rasterio.open(url_to_image) as dataset: |
103 | 104 | data = dataset.read() |
104 | 105 | drape_grid = xr.DataArray(data, dims=("band", "y", "x")) |
|
117 | 118 | pygmt.makecpt(cmap="0/51/153,255/204/0", series=[0, 256, 128]) |
118 | 119 |
|
119 | 120 | fig.grdview( |
120 | | - projection="M12c", # Mercator projection with a width of 12 centimeters |
| 121 | + projection="M12c", # Mercator projection with a width of 12 cm |
121 | 122 | region=region_3d, |
122 | 123 | grid=grd_relief, # Use elevation grid for z values |
123 | 124 | drape_grid=drape_grid, # Drape image grid for the EU flag on top |
|
126 | 127 | # Use an illumination from the azimuthal directions 0° (north) and 270° (west) with |
127 | 128 | # a normalization via a cumulative Laplace distribution for the shading |
128 | 129 | shading="+a0/270+ne0.6", |
129 | | - perspective=[157.5, 30], # Define azimuth, elevation for the 3-D plot |
| 130 | + perspective=(157.5, 30), # Define azimuth, elevation for the 3-D plot |
130 | 131 | zsize="1c", |
131 | 132 | facade_fill="darkgray", |
132 | 133 | frame=True, |
|
0 commit comments