Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint errors in datacube script #36

Merged
merged 8 commits into from
Nov 16, 2023
Prev Previous commit
Next Next commit
🔥 Remove sorting by nodata and just sort by least cloud cover
No need to sort by `s2:nodata_pixel_percentage` anymore, just get the Sentinel-2 STAC item with the least cloud cover.
weiji14 committed Nov 16, 2023
commit f65e34a9c4f72950b4f8a68a6ea2d4c580878ecd
14 changes: 7 additions & 7 deletions scripts/datacube.py
Original file line number Diff line number Diff line change
@@ -132,10 +132,10 @@ def search_sentinel2(week, aoi, cloud_cover_percentage, nodata_pixel_percentage)
Note:
The function filters Sentinel-2 items based on the specified conditions
such as geometry, date, cloud cover, and nodata pixel percentage. The
result is returned as a tuple containing the STAC catalog, Sentinel-2
items, the bounding box of the first item, and an EPSG code for the
coordinate reference system.
such as geometry, date, cloud cover, and nodata pixel percentage. Only one
result with the least cloud cover will be returned. The result is returned
as a tuple containing the STAC catalog, Sentinel-2 items, the bounding box
of the first item, and an EPSG code for the coordinate reference system.
"""

CENTROID = aoi.centroid
@@ -174,11 +174,11 @@ def search_sentinel2(week, aoi, cloud_cover_percentage, nodata_pixel_percentage)

s2_items_gdf = gpd.GeoDataFrame.from_features(s2_items.to_dict())

least_nodata_and_clouds = s2_items_gdf.sort_values(
by=["s2:nodata_pixel_percentage", "eo:cloud_cover"], ascending=True
least_clouds = s2_items_gdf.sort_values(
by=["eo:cloud_cover"], ascending=True
).index[0]

s2_items_gdf = s2_items_gdf.iloc[least_nodata_and_clouds]
s2_items_gdf = s2_items_gdf.iloc[least_clouds]
s2_items_gdf

# Get the datetime for the filtered Sentinel 2 dataframe