Home Machine Learning Cropping Landsat Scenes from their Bounding Field utilizing Python | by Conor O’Sullivan | Feb, 2024

Cropping Landsat Scenes from their Bounding Field utilizing Python | by Conor O’Sullivan | Feb, 2024

0
Cropping Landsat Scenes from their Bounding Field utilizing Python | by Conor O’Sullivan | Feb, 2024

[ad_1]

Eradicating the outer border of Landsat satellite tv for pc photos utilizing the stac file

(supply: creator)

Telling tales with satellite tv for pc photos is simple. The mesmerising landscapes do many of the work. But, visualising them takes some work resembling choosing and scaling the RGB channels. On this article, we’ll go additional. We are going to see how we are able to eliminate that ugly bounding field. Particularly, we’ll:

  • Crop and rotate Landsat scenes utilizing the stac file
  • Focus on how we are able to do that but additionally hold the geolocation of pixels

We are going to focus on key items of Python code and you will discover the complete undertaking 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 need to have a folder like Determine 1. These are all of the information out there for a Landsat stage 2 science product. We’ll be working with the highlighted information. These are the three seen mild bands and the SR_stac file.

Determine 1: Landsat level-2 science product information (supply: creator)

This explicit 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 title/ ID as a parameter. It would then load the bands (traces 8–10), stack them (line 13), scale them (line 14) and clip them (line 17).

import tifffile as tiff
import numpy as np
data_file = "./information/"

def get_rgb(ID):

# Load Blue (B2), Inexperienced (B3) and Pink (B4) bands
R = tiff.imread(data_file +'{}/{}_SR_B4.TIF'.format(ID, ID))
G = tiff.imread(data_file +'{}/{}_SR_B3.TIF'.format(ID…

[ad_2]