Hi everybody.
Welcome to the second tutorial on Google Earth Engine.
This tutorial is gonna help you complete
your Yellow Dig assignment for the week.
So, if you wanna look at the Yellow Dig prompt,
before watching this video, that might be helpful.
I'm gonna teach you in this tutorial how to draw an ROI
or a region of interest,
and then how to pull up some very basic imagery
to go into that ROI.
So, in order to draw ROIs in Google Earth Engine,
there is a way to code,
how to code with coordinates your geometry,
but it's easier to use these functions down here.
So, as I showed last week,
we have this hand function that helps us move around,
but we also have these other geometry buttons.
So for example, if we wanted a point feature,
we could drop a point
and that's created a geometry with our point.
I'm going to delete that,
because I don't wanna point right now.
We can also draw lines or polygons
or this is a rectangle.
Today I'm gonna draw a polygon
and I'm gonna put my ROI as Fort Collins,
since that's where I live.
You should use an ROI that might not be the ROI
that you wanna do your final project on,
but a location that is of of interest to you.
Okay, so I'm gonna click on this little polygon icon
and now I can start drawing.
So, I'm just gonna click around Fort Collins.
I can do as many dots as I want
and once I click back on that first dot,
it'll complete my polygon.
We can also,
if you want to look at the satellite,
you can do that.
I'm gonna keep it on the map for now.
So, when you've drawn a geometry,
if you wanna change some elements
of the geometry immediately,
you can change its name.
So, Fort Collins, you could do that.
You can also change it from a geometry
to a feature or a feature collection.
A geometry just has coordinate information.
A feature can also have properties.
So, if you want, you can add some more data to it.
For now,
I'm just gonna keep my Fort Collins geometry as a geometry.
So I'm gonna say, okay,
and you might notice that up in my script editor,
a variable has been added at the top.
So, it's taken this geometry down here
and include it as a variable here.
So, now it's ready for me to do analyses on.
Okay, I'm actually gonna turn off the geometry down here,
because I kind of find the geometry
to be distracting sometimes.
You'll see if we visualize imagery,
the geometry always sits on top of the imagery
and I don't want the imagery to be sort of shaded red.
I wanna be able to see it in full.
So, I'm gonna turn this off,
but it still exists, it's still in there.
And by the way,
if we wanted to see the coordinates,
we could go in here and see each one of those points
that I drew.
We could see the the lat and long coordinates for that.
Great.
So, I'm gonna start by importing some imagery,
some Landsat imagery.
If you remember, we talked about Lansat imagery last week,
and I'm gonna use Landsat Eight.
So, I believe Landsat four through nine are in here.
Yeah, so that it doesn't seem like they have Landsat Threes,
but four through nine are in here.
I'm gonna use Landsat Eight.
You're welcome to use another one if you want.
I'm gonna use the top of atmosphere reflectance.
You don't want the raw scenes,
those are unprocessed.
So, top of atmosphere, TOA reflectance,
and I'm just gonna say Import.
And now it's imported into my script.
We can rename it by clicking on it.
I'm gonna rename it L8, for Landsat Eight.
Another cool thing is that you can click on
this blue name of the dataset
and a little box pops up and it can,
it tells you information about that dataset.
So, for example, the dataset is from 2013 to the present.
There's more description here.
If you click on these tabs,
it tells you other information,
like it tells you the band names
and what they are describing.
So, the important information here might be that
the red band is band four,
green is B3
and blue is B2.
So, that'll be helpful
when we wanna make a true color image.
We can see some image properties.
So, it has some information about cloud cover.
We'll get into that more next week.
And then it has some terms of use,
including how you might cite or acknowledge this data.
Okay, so great.
I'm gonna click Close
and I'm gonna start processing this Landsat Eight imagery.
So, I'm gonna create a variable called Landsat Eight image.
So right now, if you see,
this is an image collection.
So, this L8 variable includes every single tile
of Landsat Eight that is available.
I don't want all those tiles,
that's way too much information.
So, I'm gonna start filtering this image collection down,
so that it's just a single image.
And the way that I do that is I'm gonna create a variable.
I'm going to put L8 dot,
and then I'm gonna filter it.
So, first I'm gonna filter it by bounds.
So, that basically means that I only want
the imagery that is touching my geometry.
So, I've said dot filter bounds.
And then within these parentheses,
I've put the name of my ROI,
so Fort Collins.
So, if I left it right here,
that would basically give me a new image collection
that is much reduced.
That only is imagery, again, touching Fort Collins,
but that's still an image collection, right?
So, if we want just an image,
we need to filter it down even more.
And there's a variety of ways that you can do that.
One of those ways is you can just get the first image,
within that image collection.
And you would do that by saying dot first.
Another way is you can get the median of those images.
You can go crazy as well.
You can get the max of all of those images.
That won't look very good, but you can do it.
I'm gonna start off by just getting the first image,
within that image collection
and then I'm gonna show you how to visualize that.
So, the function to visualize anything
in Google Earth Engine is called map add layer,
and then parentheses after that.
There's a variety of arguments
that go within this map add layer.
Again, if we want to know all of those different arguments,
we can go into the docs
and look at this function map add layer.
And let me just,
map, add layer, there you go.
So, if I click on this,
it shows the different arguments that are helpful.
So, the argument that is not italicized is required
and the arguments that are italicized are optional.
So, you need an object to visualize.
And then an optional argument is the visual parameters.
Another optional argument is the name,
the shown, the opacity.
And you can see what each of those things mean down here.
So, the image or the object
that I am visualizing is the L8 underscore image variable.
And I'm going to leave
the visualization parameters blank right now,
but it within these curly parentheses
is where they would go.
And then inside the quotation marks,
I'm just gonna name it,
I'm gonna say, this is my Landsat Eight image,
and I'm gonna run that.
It might not look very good,
but I'm gonna run it just to see what happens.
All right, so what we're looking at right now
is an entire tile of Landsat imagery.
If I want just my Fort Collins geometry.
So, remember we made that geometry.
It's much, much smaller than this tile, right?
So, if I want the imagery just to fall within that tile,
I'm gonna use the function called clip.
I'm gonna put Fort Collins in there.
So, I'm gonna run that again.
And now the imagery is just within this Fort Collins ROI
that I made.
This still doesn't look great
and there's a few things that we can do to help it.
So, I'm gonna use the inspector tool
and click on the imagery and I'm gonna see what's going on.
So, let's see if I click this.
There you go.
So, it shows the reflectance values.
The pixel that I clicked,
it shows the reflectance values for all of the bands.
So, this gives us some good information about what the range
of those bands might be.
So, within the visualization parameters,
some things that we can input here are the min and the max.
So, it's pretty clear that the max values are pretty low.
I'm gonna say the max is about 0.02.
And then also,
I'm not really sure what it's visualizing here.
We can go into the layer and click this little settings
and see what it's doing.
So, it is doing a three band visualization right now
with band one, band two and band three.
But if you remember in Landsat Eight,
the red, green, blue is bands,
bands four, three, and two.
So, red, green, blue,
red is band four,
green is band three,
and blue is band two.
So, I'm gonna put bands in here.
And when you have lists in Google Earth Engine,
you have to put them in brackets.
So, I'm gonna make my list of the three bands
that I'm gonna visualize.
Band four, band three, band two.
And then I have my min and my max.
So, I'm gonna run that again.
Okay, that looks better.
I can see some things in the landscape now.
And the min and the max also helped a bit.
There's some clouds here.
I'm not gonna worry about that right now.
But next week I'll show you how to get rid of clouds.
I'm gonna now show what happens if I use some different ways
of summarizing my image collection into an image.
So, rather than using first,
what if I use median?
What does that look like?
And it's gonna take a bit longer,
because it has to get the median,
over all of those different images.
So, it's a little bit slow.
So, if you run this on your computer
and median takes forever, that's okay.
Maybe just use first for now.
Okay, the image is kind of washed out,
so if I did median,
I might wanna change my min and my max a little bit.
Just for fuzzies, let's see what max looks like.
It's probably gonna look very white.
It's probably gonna take the image
that has like the most clouds.
Yep,
because clouds have a really high reflectance value,
remember?
So, when I put max here,
it's basically taking,
all of the pixels within this huge image collection
that have the absolute max reflectance values
and combining those into an image.
So, not the most intuitive or interpretable image ever.
I'm gonna also show mosaic.
I think the book uses mosaic a lot.
And I believe what mosaic does is,
oh,
yeah, interesting.
So, mosaic is also giving me pretty high reflectance values.
But mosaic is helpful
if you have, for example, your ROI
is in between two different tiles,
then it'll help join those tiles.
But honestly, median is,
it does the same thing.
Median also mosaics tiles.
So, the two functions that I use the most are median
and first.
Great, so this is all that you need to do
for Yellow Dig this week is draw your ROI
and then just visualize some data within it.
You can use Landsat Eight.
You're also welcome to challenge yourself
and use Landsat Nine or Seven or Five instead.
An important part of coding,
save your work.
So, click Save
and then I'm gonna not save it.
And then don't forget to get the link
by clicking this button and then copy paste this URL.
All right.