1 00:00:01,140 --> 00:00:02,580 Hi everybody. 2 00:00:02,580 --> 00:00:06,944 Welcome to the second tutorial on Google Earth Engine. 3 00:00:06,944 --> 00:00:09,600 This tutorial is gonna help you complete 4 00:00:09,600 --> 00:00:11,913 your Yellow Dig assignment for the week. 5 00:00:12,960 --> 00:00:17,250 So, if you wanna look at the Yellow Dig prompt, 6 00:00:17,250 --> 00:00:20,700 before watching this video, that might be helpful. 7 00:00:20,700 --> 00:00:25,560 I'm gonna teach you in this tutorial how to draw an ROI 8 00:00:25,560 --> 00:00:27,540 or a region of interest, 9 00:00:27,540 --> 00:00:31,308 and then how to pull up some very basic imagery 10 00:00:31,308 --> 00:00:34,290 to go into that ROI. 11 00:00:34,290 --> 00:00:38,940 So, in order to draw ROIs in Google Earth Engine, 12 00:00:38,940 --> 00:00:41,370 there is a way to code, 13 00:00:41,370 --> 00:00:46,370 how to code with coordinates your geometry, 14 00:00:47,610 --> 00:00:52,610 but it's easier to use these functions down here. 15 00:00:53,400 --> 00:00:55,440 So, as I showed last week, 16 00:00:55,440 --> 00:00:58,350 we have this hand function that helps us move around, 17 00:00:58,350 --> 00:01:01,920 but we also have these other geometry buttons. 18 00:01:01,920 --> 00:01:04,410 So for example, if we wanted a point feature, 19 00:01:04,410 --> 00:01:07,020 we could drop a point 20 00:01:07,020 --> 00:01:09,690 and that's created a geometry with our point. 21 00:01:09,690 --> 00:01:13,590 I'm going to delete that, 22 00:01:13,590 --> 00:01:15,270 because I don't wanna point right now. 23 00:01:15,270 --> 00:01:18,510 We can also draw lines or polygons 24 00:01:18,510 --> 00:01:21,150 or this is a rectangle. 25 00:01:21,150 --> 00:01:24,180 Today I'm gonna draw a polygon 26 00:01:24,180 --> 00:01:27,930 and I'm gonna put my ROI as Fort Collins, 27 00:01:27,930 --> 00:01:30,240 since that's where I live. 28 00:01:30,240 --> 00:01:34,170 You should use an ROI that might not be the ROI 29 00:01:34,170 --> 00:01:36,840 that you wanna do your final project on, 30 00:01:36,840 --> 00:01:41,840 but a location that is of of interest to you. 31 00:01:42,270 --> 00:01:46,110 Okay, so I'm gonna click on this little polygon icon 32 00:01:46,110 --> 00:01:47,913 and now I can start drawing. 33 00:01:49,920 --> 00:01:54,570 So, I'm just gonna click around Fort Collins. 34 00:01:54,570 --> 00:01:58,230 I can do as many dots as I want 35 00:01:58,230 --> 00:02:03,000 and once I click back on that first dot, 36 00:02:03,000 --> 00:02:04,623 it'll complete my polygon. 37 00:02:07,020 --> 00:02:08,310 We can also, 38 00:02:08,310 --> 00:02:10,260 if you want to look at the satellite, 39 00:02:10,260 --> 00:02:11,223 you can do that. 40 00:02:13,163 --> 00:02:15,060 I'm gonna keep it on the map for now. 41 00:02:15,060 --> 00:02:17,760 So, when you've drawn a geometry, 42 00:02:17,760 --> 00:02:19,920 if you wanna change some elements 43 00:02:19,920 --> 00:02:21,960 of the geometry immediately, 44 00:02:21,960 --> 00:02:23,700 you can change its name. 45 00:02:23,700 --> 00:02:26,520 So, Fort Collins, you could do that. 46 00:02:26,520 --> 00:02:29,040 You can also change it from a geometry 47 00:02:29,040 --> 00:02:32,040 to a feature or a feature collection. 48 00:02:32,040 --> 00:02:35,010 A geometry just has coordinate information. 49 00:02:35,010 --> 00:02:38,340 A feature can also have properties. 50 00:02:38,340 --> 00:02:41,370 So, if you want, you can add some more data to it. 51 00:02:41,370 --> 00:02:42,203 For now, 52 00:02:42,203 --> 00:02:46,880 I'm just gonna keep my Fort Collins geometry as a geometry. 53 00:02:48,180 --> 00:02:49,590 So I'm gonna say, okay, 54 00:02:49,590 --> 00:02:52,879 and you might notice that up in my script editor, 55 00:02:52,879 --> 00:02:55,740 a variable has been added at the top. 56 00:02:55,740 --> 00:02:59,040 So, it's taken this geometry down here 57 00:02:59,040 --> 00:03:02,190 and include it as a variable here. 58 00:03:02,190 --> 00:03:04,983 So, now it's ready for me to do analyses on. 59 00:03:06,420 --> 00:03:09,810 Okay, I'm actually gonna turn off the geometry down here, 60 00:03:09,810 --> 00:03:13,350 because I kind of find the geometry 61 00:03:13,350 --> 00:03:15,240 to be distracting sometimes. 62 00:03:15,240 --> 00:03:18,480 You'll see if we visualize imagery, 63 00:03:18,480 --> 00:03:20,820 the geometry always sits on top of the imagery 64 00:03:20,820 --> 00:03:24,000 and I don't want the imagery to be sort of shaded red. 65 00:03:24,000 --> 00:03:25,590 I wanna be able to see it in full. 66 00:03:25,590 --> 00:03:27,720 So, I'm gonna turn this off, 67 00:03:27,720 --> 00:03:30,210 but it still exists, it's still in there. 68 00:03:30,210 --> 00:03:31,043 And by the way, 69 00:03:31,043 --> 00:03:33,420 if we wanted to see the coordinates, 70 00:03:33,420 --> 00:03:36,510 we could go in here and see each one of those points 71 00:03:36,510 --> 00:03:37,590 that I drew. 72 00:03:37,590 --> 00:03:40,833 We could see the the lat and long coordinates for that. 73 00:03:41,940 --> 00:03:42,773 Great. 74 00:03:43,920 --> 00:03:48,920 So, I'm gonna start by importing some imagery, 75 00:03:49,590 --> 00:03:50,790 some Landsat imagery. 76 00:03:50,790 --> 00:03:55,790 If you remember, we talked about Lansat imagery last week, 77 00:03:56,130 --> 00:03:59,880 and I'm gonna use Landsat Eight. 78 00:03:59,880 --> 00:04:04,880 So, I believe Landsat four through nine are in here. 79 00:04:08,220 --> 00:04:10,770 Yeah, so that it doesn't seem like they have Landsat Threes, 80 00:04:10,770 --> 00:04:12,693 but four through nine are in here. 81 00:04:15,420 --> 00:04:16,920 I'm gonna use Landsat Eight. 82 00:04:16,920 --> 00:04:19,440 You're welcome to use another one if you want. 83 00:04:19,440 --> 00:04:23,280 I'm gonna use the top of atmosphere reflectance. 84 00:04:23,280 --> 00:04:24,840 You don't want the raw scenes, 85 00:04:24,840 --> 00:04:26,520 those are unprocessed. 86 00:04:26,520 --> 00:04:29,430 So, top of atmosphere, TOA reflectance, 87 00:04:29,430 --> 00:04:31,470 and I'm just gonna say Import. 88 00:04:31,470 --> 00:04:34,530 And now it's imported into my script. 89 00:04:34,530 --> 00:04:37,770 We can rename it by clicking on it. 90 00:04:37,770 --> 00:04:42,770 I'm gonna rename it L8, for Landsat Eight. 91 00:04:43,020 --> 00:04:45,850 Another cool thing is that you can click on 92 00:04:47,250 --> 00:04:51,450 this blue name of the dataset 93 00:04:51,450 --> 00:04:53,940 and a little box pops up and it can, 94 00:04:53,940 --> 00:04:55,830 it tells you information about that dataset. 95 00:04:55,830 --> 00:05:00,830 So, for example, the dataset is from 2013 to the present. 96 00:05:01,290 --> 00:05:03,547 There's more description here. 97 00:05:03,547 --> 00:05:05,220 If you click on these tabs, 98 00:05:05,220 --> 00:05:06,480 it tells you other information, 99 00:05:06,480 --> 00:05:09,360 like it tells you the band names 100 00:05:09,360 --> 00:05:10,980 and what they are describing. 101 00:05:10,980 --> 00:05:14,640 So, the important information here might be that 102 00:05:14,640 --> 00:05:18,030 the red band is band four, 103 00:05:18,030 --> 00:05:19,360 green is B3 104 00:05:20,820 --> 00:05:22,260 and blue is B2. 105 00:05:22,260 --> 00:05:23,280 So, that'll be helpful 106 00:05:23,280 --> 00:05:26,190 when we wanna make a true color image. 107 00:05:26,190 --> 00:05:28,620 We can see some image properties. 108 00:05:28,620 --> 00:05:32,040 So, it has some information about cloud cover. 109 00:05:32,040 --> 00:05:34,830 We'll get into that more next week. 110 00:05:34,830 --> 00:05:36,570 And then it has some terms of use, 111 00:05:36,570 --> 00:05:41,280 including how you might cite or acknowledge this data. 112 00:05:41,280 --> 00:05:42,113 Okay, so great. 113 00:05:42,113 --> 00:05:43,390 I'm gonna click Close 114 00:05:45,540 --> 00:05:50,540 and I'm gonna start processing this Landsat Eight imagery. 115 00:05:52,860 --> 00:05:57,630 So, I'm gonna create a variable called Landsat Eight image. 116 00:05:57,630 --> 00:05:59,640 So right now, if you see, 117 00:05:59,640 --> 00:06:01,350 this is an image collection. 118 00:06:01,350 --> 00:06:06,120 So, this L8 variable includes every single tile 119 00:06:06,120 --> 00:06:08,580 of Landsat Eight that is available. 120 00:06:08,580 --> 00:06:09,690 I don't want all those tiles, 121 00:06:09,690 --> 00:06:11,280 that's way too much information. 122 00:06:11,280 --> 00:06:15,150 So, I'm gonna start filtering this image collection down, 123 00:06:15,150 --> 00:06:18,270 so that it's just a single image. 124 00:06:18,270 --> 00:06:20,790 And the way that I do that is I'm gonna create a variable. 125 00:06:20,790 --> 00:06:25,790 I'm going to put L8 dot, 126 00:06:25,950 --> 00:06:26,940 and then I'm gonna filter it. 127 00:06:26,940 --> 00:06:30,210 So, first I'm gonna filter it by bounds. 128 00:06:30,210 --> 00:06:33,240 So, that basically means that I only want 129 00:06:33,240 --> 00:06:36,270 the imagery that is touching my geometry. 130 00:06:36,270 --> 00:06:38,310 So, I've said dot filter bounds. 131 00:06:38,310 --> 00:06:40,200 And then within these parentheses, 132 00:06:40,200 --> 00:06:42,660 I've put the name of my ROI, 133 00:06:42,660 --> 00:06:44,220 so Fort Collins. 134 00:06:44,220 --> 00:06:46,200 So, if I left it right here, 135 00:06:46,200 --> 00:06:49,350 that would basically give me a new image collection 136 00:06:49,350 --> 00:06:50,370 that is much reduced. 137 00:06:50,370 --> 00:06:52,920 That only is imagery, again, touching Fort Collins, 138 00:06:56,040 --> 00:06:57,690 but that's still an image collection, right? 139 00:06:57,690 --> 00:06:59,280 So, if we want just an image, 140 00:06:59,280 --> 00:07:01,950 we need to filter it down even more. 141 00:07:01,950 --> 00:07:04,170 And there's a variety of ways that you can do that. 142 00:07:04,170 --> 00:07:08,520 One of those ways is you can just get the first image, 143 00:07:08,520 --> 00:07:09,960 within that image collection. 144 00:07:09,960 --> 00:07:12,930 And you would do that by saying dot first. 145 00:07:12,930 --> 00:07:17,700 Another way is you can get the median of those images. 146 00:07:17,700 --> 00:07:18,960 You can go crazy as well. 147 00:07:18,960 --> 00:07:23,160 You can get the max of all of those images. 148 00:07:23,160 --> 00:07:25,920 That won't look very good, but you can do it. 149 00:07:25,920 --> 00:07:29,190 I'm gonna start off by just getting the first image, 150 00:07:29,190 --> 00:07:30,960 within that image collection 151 00:07:30,960 --> 00:07:35,610 and then I'm gonna show you how to visualize that. 152 00:07:35,610 --> 00:07:40,022 So, the function to visualize anything 153 00:07:40,022 --> 00:07:45,003 in Google Earth Engine is called map add layer, 154 00:07:46,320 --> 00:07:48,810 and then parentheses after that. 155 00:07:48,810 --> 00:07:50,670 There's a variety of arguments 156 00:07:50,670 --> 00:07:53,190 that go within this map add layer. 157 00:07:53,190 --> 00:07:56,130 Again, if we want to know all of those different arguments, 158 00:07:56,130 --> 00:07:58,410 we can go into the docs 159 00:07:58,410 --> 00:08:01,323 and look at this function map add layer. 160 00:08:03,480 --> 00:08:08,463 And let me just, 161 00:08:10,740 --> 00:08:12,600 map, add layer, there you go. 162 00:08:12,600 --> 00:08:14,250 So, if I click on this, 163 00:08:14,250 --> 00:08:18,000 it shows the different arguments that are helpful. 164 00:08:18,000 --> 00:08:22,560 So, the argument that is not italicized is required 165 00:08:22,560 --> 00:08:26,340 and the arguments that are italicized are optional. 166 00:08:26,340 --> 00:08:29,310 So, you need an object to visualize. 167 00:08:29,310 --> 00:08:34,310 And then an optional argument is the visual parameters. 168 00:08:35,580 --> 00:08:39,060 Another optional argument is the name, 169 00:08:39,060 --> 00:08:40,950 the shown, the opacity. 170 00:08:40,950 --> 00:08:44,043 And you can see what each of those things mean down here. 171 00:08:45,480 --> 00:08:48,360 So, the image or the object 172 00:08:48,360 --> 00:08:53,360 that I am visualizing is the L8 underscore image variable. 173 00:08:57,390 --> 00:09:00,060 And I'm going to leave 174 00:09:00,060 --> 00:09:03,840 the visualization parameters blank right now, 175 00:09:03,840 --> 00:09:08,520 but it within these curly parentheses 176 00:09:08,520 --> 00:09:10,260 is where they would go. 177 00:09:10,260 --> 00:09:12,540 And then inside the quotation marks, 178 00:09:12,540 --> 00:09:13,500 I'm just gonna name it, 179 00:09:13,500 --> 00:09:17,820 I'm gonna say, this is my Landsat Eight image, 180 00:09:17,820 --> 00:09:19,530 and I'm gonna run that. 181 00:09:19,530 --> 00:09:20,910 It might not look very good, 182 00:09:20,910 --> 00:09:23,283 but I'm gonna run it just to see what happens. 183 00:09:26,160 --> 00:09:30,450 All right, so what we're looking at right now 184 00:09:30,450 --> 00:09:34,803 is an entire tile of Landsat imagery. 185 00:09:37,830 --> 00:09:42,360 If I want just my Fort Collins geometry. 186 00:09:42,360 --> 00:09:44,160 So, remember we made that geometry. 187 00:09:44,160 --> 00:09:46,460 It's much, much smaller than this tile, right? 188 00:09:48,030 --> 00:09:51,930 So, if I want the imagery just to fall within that tile, 189 00:09:51,930 --> 00:09:54,330 I'm gonna use the function called clip. 190 00:09:54,330 --> 00:09:57,000 I'm gonna put Fort Collins in there. 191 00:09:57,000 --> 00:09:58,500 So, I'm gonna run that again. 192 00:09:58,500 --> 00:10:03,500 And now the imagery is just within this Fort Collins ROI 193 00:10:03,630 --> 00:10:04,740 that I made. 194 00:10:04,740 --> 00:10:07,500 This still doesn't look great 195 00:10:07,500 --> 00:10:09,150 and there's a few things that we can do to help it. 196 00:10:09,150 --> 00:10:11,730 So, I'm gonna use the inspector tool 197 00:10:11,730 --> 00:10:14,733 and click on the imagery and I'm gonna see what's going on. 198 00:10:16,320 --> 00:10:20,280 So, let's see if I click this. 199 00:10:20,280 --> 00:10:21,113 There you go. 200 00:10:21,113 --> 00:10:23,250 So, it shows the reflectance values. 201 00:10:23,250 --> 00:10:24,480 The pixel that I clicked, 202 00:10:24,480 --> 00:10:27,453 it shows the reflectance values for all of the bands. 203 00:10:28,350 --> 00:10:32,010 So, this gives us some good information about what the range 204 00:10:32,010 --> 00:10:33,840 of those bands might be. 205 00:10:33,840 --> 00:10:36,990 So, within the visualization parameters, 206 00:10:36,990 --> 00:10:40,620 some things that we can input here are the min and the max. 207 00:10:40,620 --> 00:10:45,390 So, it's pretty clear that the max values are pretty low. 208 00:10:45,390 --> 00:10:49,590 I'm gonna say the max is about 0.02. 209 00:10:49,590 --> 00:10:50,610 And then also, 210 00:10:50,610 --> 00:10:52,830 I'm not really sure what it's visualizing here. 211 00:10:52,830 --> 00:10:56,760 We can go into the layer and click this little settings 212 00:10:56,760 --> 00:10:59,550 and see what it's doing. 213 00:10:59,550 --> 00:11:04,550 So, it is doing a three band visualization right now 214 00:11:07,800 --> 00:11:10,710 with band one, band two and band three. 215 00:11:10,710 --> 00:11:13,590 But if you remember in Landsat Eight, 216 00:11:13,590 --> 00:11:16,773 the red, green, blue is bands, 217 00:11:20,880 --> 00:11:23,820 bands four, three, and two. 218 00:11:23,820 --> 00:11:25,290 So, red, green, blue, 219 00:11:25,290 --> 00:11:27,120 red is band four, 220 00:11:27,120 --> 00:11:29,160 green is band three, 221 00:11:29,160 --> 00:11:30,390 and blue is band two. 222 00:11:30,390 --> 00:11:33,180 So, I'm gonna put bands in here. 223 00:11:33,180 --> 00:11:36,510 And when you have lists in Google Earth Engine, 224 00:11:36,510 --> 00:11:38,853 you have to put them in brackets. 225 00:11:39,870 --> 00:11:42,060 So, I'm gonna make my list of the three bands 226 00:11:42,060 --> 00:11:43,140 that I'm gonna visualize. 227 00:11:43,140 --> 00:11:45,663 Band four, band three, band two. 228 00:11:46,530 --> 00:11:47,760 And then I have my min and my max. 229 00:11:47,760 --> 00:11:49,210 So, I'm gonna run that again. 230 00:11:50,610 --> 00:11:52,080 Okay, that looks better. 231 00:11:52,080 --> 00:11:56,340 I can see some things in the landscape now. 232 00:11:56,340 --> 00:11:59,670 And the min and the max also helped a bit. 233 00:11:59,670 --> 00:12:01,020 There's some clouds here. 234 00:12:01,020 --> 00:12:03,870 I'm not gonna worry about that right now. 235 00:12:03,870 --> 00:12:07,020 But next week I'll show you how to get rid of clouds. 236 00:12:07,020 --> 00:12:12,020 I'm gonna now show what happens if I use some different ways 237 00:12:12,030 --> 00:12:14,520 of summarizing my image collection into an image. 238 00:12:14,520 --> 00:12:16,740 So, rather than using first, 239 00:12:16,740 --> 00:12:17,940 what if I use median? 240 00:12:17,940 --> 00:12:19,190 What does that look like? 241 00:12:23,040 --> 00:12:24,300 And it's gonna take a bit longer, 242 00:12:24,300 --> 00:12:26,490 because it has to get the median, 243 00:12:26,490 --> 00:12:29,373 over all of those different images. 244 00:12:31,710 --> 00:12:33,390 So, it's a little bit slow. 245 00:12:33,390 --> 00:12:35,580 So, if you run this on your computer 246 00:12:35,580 --> 00:12:37,410 and median takes forever, that's okay. 247 00:12:37,410 --> 00:12:39,273 Maybe just use first for now. 248 00:12:43,680 --> 00:12:45,510 Okay, the image is kind of washed out, 249 00:12:45,510 --> 00:12:46,620 so if I did median, 250 00:12:46,620 --> 00:12:50,910 I might wanna change my min and my max a little bit. 251 00:12:50,910 --> 00:12:54,150 Just for fuzzies, let's see what max looks like. 252 00:12:54,150 --> 00:12:56,460 It's probably gonna look very white. 253 00:12:56,460 --> 00:12:59,040 It's probably gonna take the image 254 00:12:59,040 --> 00:13:00,810 that has like the most clouds. 255 00:13:00,810 --> 00:13:01,710 Yep, 256 00:13:01,710 --> 00:13:04,050 because clouds have a really high reflectance value, 257 00:13:04,050 --> 00:13:04,883 remember? 258 00:13:04,883 --> 00:13:06,000 So, when I put max here, 259 00:13:06,000 --> 00:13:07,503 it's basically taking, 260 00:13:09,120 --> 00:13:12,390 all of the pixels within this huge image collection 261 00:13:12,390 --> 00:13:16,200 that have the absolute max reflectance values 262 00:13:16,200 --> 00:13:18,240 and combining those into an image. 263 00:13:18,240 --> 00:13:23,240 So, not the most intuitive or interpretable image ever. 264 00:13:27,840 --> 00:13:30,990 I'm gonna also show mosaic. 265 00:13:30,990 --> 00:13:33,690 I think the book uses mosaic a lot. 266 00:13:33,690 --> 00:13:37,173 And I believe what mosaic does is, 267 00:13:38,520 --> 00:13:39,353 oh, 268 00:13:42,480 --> 00:13:43,313 yeah, interesting. 269 00:13:43,313 --> 00:13:47,553 So, mosaic is also giving me pretty high reflectance values. 270 00:13:50,190 --> 00:13:51,540 But mosaic is helpful 271 00:13:51,540 --> 00:13:54,240 if you have, for example, your ROI 272 00:13:54,240 --> 00:13:56,370 is in between two different tiles, 273 00:13:56,370 --> 00:13:59,190 then it'll help join those tiles. 274 00:13:59,190 --> 00:14:02,103 But honestly, median is, 275 00:14:03,420 --> 00:14:04,770 it does the same thing. 276 00:14:04,770 --> 00:14:07,113 Median also mosaics tiles. 277 00:14:07,950 --> 00:14:11,550 So, the two functions that I use the most are median 278 00:14:11,550 --> 00:14:12,453 and first. 279 00:14:18,750 --> 00:14:21,120 Great, so this is all that you need to do 280 00:14:21,120 --> 00:14:24,420 for Yellow Dig this week is draw your ROI 281 00:14:24,420 --> 00:14:27,870 and then just visualize some data within it. 282 00:14:27,870 --> 00:14:29,250 You can use Landsat Eight. 283 00:14:29,250 --> 00:14:31,410 You're also welcome to challenge yourself 284 00:14:31,410 --> 00:14:35,553 and use Landsat Nine or Seven or Five instead. 285 00:14:36,630 --> 00:14:38,820 An important part of coding, 286 00:14:38,820 --> 00:14:41,070 save your work. 287 00:14:41,070 --> 00:14:42,640 So, click Save 288 00:14:44,370 --> 00:14:48,420 and then I'm gonna not save it. 289 00:14:48,420 --> 00:14:50,430 And then don't forget to get the link 290 00:14:50,430 --> 00:14:54,840 by clicking this button and then copy paste this URL. 291 00:14:54,840 --> 00:14:55,673 All right.