Skip to content

Commit

Permalink
Enable searching of sentinel data
Browse files Browse the repository at this point in the history
  • Loading branch information
plant99 committed Sep 29, 2020
1 parent c6305f8 commit e9bb468
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions felicette/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from felicette.utils.file_manager import check_sat_path, file_paths_wrt_id
from felicette.sat_downloader import (
download_landsat_data,
search_landsat_data,
search_satellite_data,
preview_landsat_image,
)
from felicette.utils.sys_utils import exit_cli, remove_dir
Expand Down Expand Up @@ -68,7 +68,7 @@ def main(coordinates, location_name, pan_enhancement, no_preview, vegetation, ve
coordinates = geocoder_util(location_name)

# unless specified, cloud_cover_lt is 10
landsat_item = search_landsat_data(coordinates, 10)
landsat_item = search_satellite_data(coordinates, 10)

# check if directory exists to save the data for this product id
check_sat_path(landsat_item._data["id"])
Expand Down
15 changes: 10 additions & 5 deletions felicette/sat_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ def handle_prompt_response(response):
else:
exit_cli(rprint, "[red]Sorry, invalid response. Exiting :([/red]")


def search_landsat_data(coordinates, cloud_cover_lt):
def search_satellite_data(coordinates, cloud_cover_lt, product="landsat-8-l1"):
"""
coordinates: bounding box's coordinates
cloud_cover_lt: maximum cloud cover
product: landsat-8-l1, sentinel-2-l1c
"""
search = Search(
bbox=get_tiny_bbox(coordinates),
query={
"eo:cloud_cover": {"lt": cloud_cover_lt},
"collection": {"eq": "landsat-8-l1"},
"collection": {"eq": product},
},
sort=[{"field": "eo:cloud_cover", "direction": "asc"}],
)
Expand All @@ -39,9 +43,10 @@ def search_landsat_data(coordinates, cloud_cover_lt):
search_items = search.items()
if not len(search_items):
exit_cli(print, "No data matched your search, please try different parameters.")
landsat_item = search_items[0]
return landsat_item

# return the first result
item = search_items[0]
return item

def preview_landsat_image(landsat_item):
paths = file_paths_wrt_id(landsat_item._data["id"])
Expand Down

0 comments on commit e9bb468

Please sign in to comment.