Remove landsat 7 black stripes from QGIS

I figured this out on my own!

This is a manual solution.

So first, you have a raster file as follows: (in my case, I downloaded it from Google Earth Engine).

landsat black stripes
This particular image is from August 26, 2003. Can you guess where?

Those black stripes are from when the satellite that took the picture of this place (Landsat #7) broke. It broke four years after it was launched. Poor thing. And yet it is still up there in the heavens, orbiting Earth, and faithfully taking images of us from above. It’s been over 20 years now!

And you can see that most of the image is okay, just the black stripes are no good. And actually, the further out you get to the edges of the image, even the colored pixels have faulty distortions in them.

Any case, though, I wanna get rid of the black stripes so the image can look a little prettier.

First, click on the Identify tool in the QGIS tool bar (circle 1). Once you’ve clicked on the Identify tool, you can click anywhere on the image, and it will tell you what value the pixel you’re clicking on has. So click on the black stripes (zoom in so you click exactly on the stripe) — this is circle 2 — and then you will see in a left-hand pane what the value is (circle 3). As you can see, for the black stripes, the values are coded as nan. NAN stands for “not a number”, scientists and computer people always use very technical terms, you see.

landsat black stripes 2

Well, since the black stripes are coded as “nan”, we should be able to easily isolate them, and get rid of them! And it was easy, once you find out how, and this is how to do it:

Go to the menu bar >> click the “Raster” pull-down menu >> click “Extraction” >> click “Clipper”.

You’ll get this nice pop-up box. And there’s four easy steps to getting it to do what you want:

landsat black stripes 3

Step 1: use the pull-down arrow to pick the correct raster file with black stripes that you’re trying to fix.

Step 2: When it gets fixed, it’s going to create a whole new file with the corrections. So give a name to this new file.

Step 3: Click the box next to “No data value”. And then I’m not entirely sure what the story of the “0” is next to that — you can choose any number. I left it at 0.

Step 4: Last step, it won’t let you press “ok” unless you first specify what section of the image you want fixed. You can very easily zoom your image behind the pop-up box the way you want it, and then just click and create the reddish box. And that will be the “extent”. The coordinates in the x and y boxes will populate automatically.

Then you press okay!

And, gentle folk, you see the result. The new raster file that’s created will automatically pop up, and look! White stripes instead of black. Except they’re not really white. They’re transparent. Which means you can add another image underneath to fill in, or do whatever you want to soften the look of the stripes.

landsat black stripes 4

Ta-da! The end.



The latest Landsat images on Earth Engine

I had thought that Google’s big library of satellite images was no longer furnishing us with the latest Landsat images. I was using the same lines of code I always had been, and I could never find images past April 2017.

Well, I figured out what the problem is. The images are there, alright. But they have been reorganized and there are new paths to accessing them. So it was a simple matter to sort out! I went to this website and I clicked on the Landsat libraries I wanted, and voila — I found the new pathways that I need. I tried them out, and yes indeed, I saw Landsat images in the areas I wanted from within the last week (so mid-September 2019).

I had earlier written a blog post decrying the loss of current Landsat images on Earth Engine, and giving undue credit to the Europeans for filling in the gap, to top it all off … glad I have things sorted out now.


Those cool sliders that show “before” and “after” images

I wanted to look at some satellite images from Hurricane Dorian, and I found a lot of them — specifically Grand Bahama and the Abaco Islands — up on Google’s big library of satellite images.

It was cool, because when I was for example searching on September 9, there were already images of the Bahamas posted that were captured on September 8. That is quite a quick response time!

I wanted to make a feature where you can slide back and forth between the before-and-after of Hurricane Dorian. I had heard about this new app called Flourish, and lo-and-behold: you can get a slider like that for free. You just have to create an account, and then you upload the “before” and “after” images you want to compare.

Here’s mine comparing Great Abaco Island from August 16 (before) to September 5 (after).


You can see that the storm has kicked up a lot of sediment in the water. If that sediment was leached from the land (it kind of looks like it; you can see curls of sediment smoking their way into the water) then that can have repercussions for the land surface of Great Abaco Island.

By the way, did you ever read the “Lost Girl” books? They were set on a deserted speck of the Abaco Islands.

Now, that is a comparison of two images that are just weeks apart in capture; so how about looking at changes in an island’s land surface over a few decades? I made another before-and-after slider image of Tangier Island in the Chesapeake Bay. The “before” image is actually from Landsat, and it is from 1992, so you see it looks quite a bit blurrier than the newer Sentinel-2 image. Times have changed, and so have satellites.

Looks like Tangier has lost quite a bit of ground; both in the north, and on that smaller eastern island. The spit of sand in the south has changed, too.

By the way, have you read “Jacob have I loved”? It’s set on a seemingly fictional Chesapeake island very similar to Tangier and Smith Islands. Oh, it is so good!



Google Earth Engine no longer adds Landsat images .. WRONG!

EDIT: I have finally discovered the trick to getting the latest Landsat images on Google Earth Engine … which means my whole blog post below is incorrect. I had a feeling it would turn out like this, because honestly? Whenever you start giving too much credit to Europeans, that should be the red flag to let you know, “something ain’t right.”

But I will leave this blog post up, so if anyone else is having the same issues, they can find it and then find the solution here.

Note: if you want to know more about why satellites like Landsat are important, see this animation or this animation.

I used Google Earth Engine to complete a large part of my Ph.D. dissertation.  I needed lots of images taken by satellites. Like, I needed thousands.

There’s a couple ways to get these images (for free!) You can go to a NASA website, and make an order. You have to do a lot of clicking to get it done, and then you have to wait a few days for the order to show up in your email. Then you have to download all the images. They take up a lot of room on your laptop. You have to figure out how to organize them, and then you have to load them into whatever computer program you’re going to use to analyze those images.

Or you can use Google Earth Engine. As much as I hate to give more power and control over to Google, this feature is very helpful. They already have all the millions of satellite images out there uploaded onto the Google servers. Instead of waiting a few days for a NASA order to come through, you can access those images with just a few lines of code in Google Earth Engine. You don’t ever have to download the images to your own computer or laptop, because you can analyze them right there in Earth Engine. The whole process is streamlined, you save so much time, and you don’t clog your harddrive up with huge satellite files.

Well, that’s all in the past now. NASA has apparently given up cooperating with Google Earth Engine. I tried to search if there was an announcement made to that effect, but I didn’t find anything. But it is a fact that if you search for Landsat images on Earth Engine, you will easily dredge up old images, going back to the 1970s. But there are no new images, not for Landsat-7 and not for Landsat-8. In fact, there are no Landsat images past April 30, 2017. Hmmm. I wonder what changes engulfed NASA’s ultimate leadership right around then, so that the ripple effects eventually led to this change in April 2017?

At least, they did not delete all the images that had already been uploaded. So images from the 1970s to April 2017 are still available.

If I’m wrong about this, and the new images are up there somewhere, someone please let me know. I have searched a couple spots on the globe and it is the same every time – nothing new after April 2017.

Yesterday, I searched for Houston in March 2019. I wanted images from the sky of that terrible oil fire that occurred. But I found no Landsat images. However, I realized there was potentially a work-around. The Europeans have launched their own satellites, and thank goodness, because ever since 2016, they have been loading their images from Sentinel-2 onto Google Earth Engine. And they are still loading away — looks like Trump can’t stop them. There were in fact 18 images from the Sentinel-2 satellite for Houston sprinkled between March 1 and April 15, 2019.

Alas for me though — no image showed the black smoke of the fire. That was what I wanted. The fire started on March 17. The first satellite image after the fire (March 18; below) had a thin coverlet of clouds covering Houston, and you can’t see anything through it.

Houston March 18 2019
Sentinel 2 image for Houston, March 18, 2019. Bands: Red, green, blue.


The next satellite image came on March 20, but alas again — there’s no more fire to be seen. Do you see black smoke?

Houston March 20 2019
Sentinel 2 image for Houston, March 20, 2019. Bands: short-wave IR, near IR, and blue.

That black dot in these images is supposed to be the location of the company that started the fire, or there-abouts. Zooming in a little closer …

Houston March 20 2019 zoomed
Sentinel 2 image for Houston, March 20, 2019. Bands: short-wave IR, near IR, and blue.

Well, maybe that is black smoke, but I don’t know that it’s going to convince any one.

Sentinel-2 has a band for “coastal aerosol”. Maybe that will be the key to being able to tell where the plume of black smoke is.

My Earth Engine code for getting these images is here.