File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Clipping grid values
3
+ --------------------
4
+ The :meth:`pygmt.grdclip` method allows to clip defined ranges of grid values.
5
+ In the example shown below we set all elevation values (grid points) smaller
6
+ than 0 m (in general the bathymetric part of the grid) to a common value of
7
+ -2000 m via the ``below`` parameter.
8
+ """
9
+
10
+ import pygmt
11
+
12
+ fig = pygmt .Figure ()
13
+
14
+ # Define region of interest around Iceland
15
+ region = [- 28 , - 10 , 62 , 68 ]
16
+
17
+ # Load sample grid (3 arc minute global relief) in target area
18
+ grid = pygmt .datasets .load_earth_relief (resolution = "03m" , region = region )
19
+
20
+ # Plot original grid
21
+ fig .basemap (region = region , projection = "M12c" , frame = ["f" , '+t"original grid"' ])
22
+ fig .grdimage (grid = grid , cmap = "oleron" )
23
+
24
+ # Shift plot origin of the second map by "width of the first map + 0.5 cm"
25
+ # in x direction
26
+ fig .shift_origin (xshift = "w+0.5c" )
27
+
28
+ # Set all grid points < 0 m to a value of -2000 m.
29
+ grid = pygmt .grdclip (grid , below = [0 , - 2000 ])
30
+
31
+ # Plot clipped grid
32
+ fig .basemap (region = region , projection = "M12c" , frame = ["f" , '+t"clipped grid"' ])
33
+ fig .grdimage (grid = grid )
34
+ fig .colorbar (frame = ["x+lElevation" , "y+lm" ], position = "JMR+o0.5c/0c+w8c" )
35
+
36
+ fig .show ()
You can’t perform that action at this time.
0 commit comments