The API.search() method provides a high-level way to search for scenes using common parameters like dataset, latitude, longitude, start_date, end_date, and max_cloud_cover.
import json
from landsatxplore.api import API
api = API(username, password)
# Search for Landsat TM scenes
scenes = api.search(
dataset='landsat_tm_c2_l1',
latitude=50.85,
longitude=-4.35,
start_date='1995-01-01',
end_date='1995-10-01',
max_cloud_cover=10
)
print(f"{len(scenes)} scenes found.")
for scene in scenes:
print(scene['acquisition_date'].strftime('%Y-%m-%d'))
# Example: Write scene footprints to disk
fname = f"{scene['landsat_product_id']}.geojson"
with open(fname, "w") as f:
json.dump(scene['spatial_coverage'].__geo_interface__, f)
api.logout()