Skip to content

Commit

Permalink
Translate between landsat sun_azimuth and STAC sun_azimuth.
Browse files Browse the repository at this point in the history
  • Loading branch information
lossyrob committed Mar 28, 2021
1 parent 95396f1 commit 5df1c1e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stactools_landsat/stactools/landsat/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ def create_stac_item(
# view
item.ext.enable('view')
item.ext.view.off_nadir = mtl_metadata.off_nadir
item.ext.view.sun_azimuth = mtl_metadata.sun_azimuth
item.ext.view.sun_elevation = mtl_metadata.sun_elevation
# Sun Azimuth in landsat metadata is -180 to 180 from north, west being negative.
# In STAC, it's 0 to 360 clockwise from north.
sun_azimuth = mtl_metadata.sun_azimuth
if sun_azimuth < 180:
sun_azimuth = 360 + sun_azimuth
item.ext.view.sun_azimuth = sun_azimuth

# projection
item.ext.enable('projection')
Expand Down

0 comments on commit 5df1c1e

Please sign in to comment.