Code Monkey home page Code Monkey logo

Comments (5)

Berhinj avatar Berhinj commented on July 28, 2024 1

FYI Element 84 is aware about these confusions and announced aligning processing baseline and metadata in the coming months :)

from stackstac.

clausmichele avatar clausmichele commented on July 28, 2024

It should be due to the fact that the newest version applies automatically offset and scale to the data, so that you get the reflectance value and not the digital number. However, in this case there seems to be an issue, since the offset has been introduced with data starting from 2023 onwards.

Did you inspect the Items returned by your query checking the scale and offset values in them?

Related issues to the new processing baseline 4.0 which introduced the offset:
Element84/earth-search#9
Element84/earth-search#23

from stackstac.

waltersdan avatar waltersdan commented on July 28, 2024

Ah ok, I see! I did not see the addition of the default rescale=True to stack(). We had our own rescaling in place, so this was a breaking change.

Looking at the first item in the query above, it has s2:processing_baseline = 05.00 so the offset should be applied. The property earthsearch:boa_offset_applied = True. However, raster:bands offset=-0.1. So if stackstac is using the raster:bands property, then it looks like it is wrong for this item. You could use earthsearch:boa_offset_applied but I suppose that is unique the Element-84 STAC.

In our own processing, we have been using the earthsearch:boa_offset_applied. It does complicate things as you have to check both the processing baseline, and whether earthsearch:boa_offset_applied exists and is False for a given item. The property doesn't exist for some items, in which case it becomes None instead of False after calling stack().

from stackstac.

clausmichele avatar clausmichele commented on July 28, 2024

Setting rescale=False gives you the correct DN value. So, as you understood, the issue is with the Element84 metadata.

import stackstac
from pystac_client import Client
geom = {'type': 'Polygon',
 'coordinates': [[(-126.37, 50.43),
   (-126.35, 50.43),
   (-126.35, 50.45),
   (-126.37, 50.45),
   (-126.37, 50.43)]]}
start_date = '2020-07-01'
end_date = '2020-07-03'
url = "https://earth-search.aws.element84.com/v1"
cat = Client.open(url)
date_query = start_date+'/'+end_date
params = {
"intersects": geom,
"collections": ["sentinel-2-l2a"],
"datetime": date_query,}
search = cat.search(**params)
items = search.item_collection()
stack = stackstac.stack(
    items,
    assets=['blue'],
    bounds_latlon=[-126.37,50.43,-126.35,50.45],
    resolution=10,
    epsg=32609,
    rescale=False
    )
print(stack[0,0,0,0].to_numpy())
> 3176.0

from stackstac.

waltersdan avatar waltersdan commented on July 28, 2024

Great, thanks for the replies! I'll close the issue

from stackstac.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.