Eradicating the outer border of Landsat satellite tv for pc photos utilizing the stac file
![Towards Data Science](https://miro.medium.com/v2/resize:fill:48:48/1*CJe3891yB1A1mzMdqemkdg.jpeg)
Telling tales with satellite tv for pc photos is simple. The mesmerising landscapes do a lot of the work. But, visualising them takes some work akin to choosing and scaling the RGB channels. On this article, we’ll go additional. We’ll see how we are able to eliminate that ugly bounding field. Particularly, we’ll:
Crop and rotate Landsat scenes utilizing the stac fileDiscuss how we are able to do that but additionally preserve the geolocation of pixels
We’ll focus on key items of Python code and you could find the complete challenge on GitHub.
We begin by downloading a Landsat scene. You are able to do this utilizing the EarthExplorer portal. Alternatively, if you wish to use Python, the article beneath takes you thru the method:
Ultimately, you must have a folder like Determine 1. These are all of the information obtainable for a Landsat degree 2 science product. We’ll be working with the highlighted information. These are the three seen mild bands and the SR_stac file.
This specific scene was taken above Cape City, South Africa. To see this we visualise the seen mild bands utilizing the get_rgb perform. This takes the file identify/ ID as a parameter. It’ll then load the bands (strains 8–10), stack them (line 13), scale them (line 14) and clip them (line 17).
import tifffile as tiffimport numpy as npdata_file = “./knowledge/”
def get_rgb(ID):
# Load Blue (B2), Inexperienced (B3) and Crimson (B4) bandsR = tiff.imread(data_file +'{}/{}_SR_B4.TIF’.format(ID, ID))G = tiff.imread(data_file +'{}/{}_SR_B3.TIF’.format(ID…