@@ -11,7 +11,7 @@ Since the data _cube_ holds in it the information about each band, computing the
11
11
12
12
``` Julia
13
13
using RemoteS, GMT
14
- N = ndvi (" c:/v/ LC08_L1TP_20210525_02_cube.tiff" );
14
+ N = ndvi (" LC08_L1TP_20210525_02_cube.tiff" );
15
15
imshow (N, colorbar= true )
16
16
```
17
17
@@ -23,7 +23,7 @@ The spectral indices functions all have a ``threshold`` value that will NaNify a
23
23
Below we wipe out all values < 0.4 to show only the _ Green stuff_
24
24
25
25
``` Julia
26
- N = ndvi (" c:/v/ LC08_L1TP_20210525_02_cube.tiff" , threshold= 0.4 );
26
+ N = ndvi (" LC08_L1TP_20210525_02_cube.tiff" , threshold= 0.4 );
27
27
imshow (N, dpi= 150 , colorbar= 1 )
28
28
```
29
29
@@ -40,23 +40,23 @@ and see what we get.
40
40
41
41
``` Julia
42
42
# Compute a mask based on the condition that threshold >= 0.4
43
- mask = ndvi (" c:/v/ LC08_L1TP_20210525_02_cube.tiff" , threshold= 0.4 , mask= true );
43
+ mask = ndvi (" LC08_L1TP_20210525_02_cube.tiff" , threshold= 0.4 , mask= true );
44
44
```
45
45
46
46
To mask out the true color image the best way is to use the ``` mask ``` as the alpha band.
47
47
To make it easier we will recalculate the true color image here.
48
48
49
49
``` Julia
50
50
# Recalculate the true color image
51
- Irgb = truecolor (" c:/v/ LC08_L1TP_20210525_02_cube.tiff" );
51
+ Irgb = truecolor (" LC08_L1TP_20210525_02_cube.tiff" );
52
52
53
53
# Apply the mask
54
- image_alpha! (Irgb, mask);
54
+ image_alpha! (Irgb, alpha_band = mask, burn = 1 );
55
55
56
- # And save it to disk so that we can visualize the result
57
- gmtwrite (" c:/v/ rgb_masked.tiff" , Irgb)
56
+ # And save it to disk
57
+ gmtwrite (" rgb_masked.tiff" , Irgb)
58
58
59
- imshow (" c:/v/rgb_masked.tiff " )
59
+ imshow (Irgb )
60
60
```
61
61
62
62
``` @raw html
@@ -70,16 +70,20 @@ To achieve that we use the ``mask`` option with a negative number.
70
70
71
71
``` Julia
72
72
# Compute a mask based on the condition that threshold >= 0.4
73
- mask_inv = ndvi (" c:/v/LC08_L1TP_20210525_02_cube.tiff" , threshold= 0.4 , mask= - 1 );
74
- image_alpha! (Irgb, mask_inv);
75
- gmtwrite (" c:/v/rgb_inv_masked.tiff" , Irgb)
73
+ mask_inv = ndvi (" LC08_L1TP_20210525_02_cube.tiff" , threshold= 0.4 , mask= - 1 )
74
+ ;
75
+ # Recompute the true color image that was modified by the ``image_alpha!`` step above
76
+ Irgb = truecolor (" LC08_L1TP_20210525_02_cube.tiff" );
77
+
78
+ image_alpha! (Irgb, alpha_band= mask_inv, burn= 1 );
79
+ gmtwrite (" rgb_inv_masked.tiff" , Irgb)
76
80
```
77
81
78
82
Plot the green vegetation that passed the NDVI threshold test and the other part, side by side.
79
83
80
84
``` Julia
81
- grdimage (" c:/v/ rgb_masked.tiff" , region= (502380 ,514200 ,4311630 ,4321420 ), figsize= 8 , frame= :bare )
82
- grdimage! (" c:/v/ rgb_inv_masked.tiff" , figsize= 8 , projection= :linear , xshift= 8 , frame= :bare , show= true )
85
+ grdimage (" rgb_masked.tiff" , region= (502380 ,514200 ,4311630 ,4321420 ), figsize= 8 , frame= :bare )
86
+ grdimage! (" rgb_inv_masked.tiff" , figsize= 8 , projection= :linear , xshift= 8 , frame= :bare , show= true )
83
87
```
84
88
85
89
``` @raw html
0 commit comments