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

Sentinel-1-RTC proj metadata issues #158

Closed
scottyhq opened this issue Jan 9, 2023 · 4 comments
Closed

Sentinel-1-RTC proj metadata issues #158

scottyhq opened this issue Jan 9, 2023 · 4 comments

Comments

@scottyhq
Copy link

scottyhq commented Jan 9, 2023

I noticed recently that proj:shape and proj:bbox are incorrect for some S1 RTC products. According to https://github.com/stac-extensions/projection#projshape shape should be in Y,X order, but s1-rtc has it flipped:

https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-1-rtc/items/S1A_IW_GRDH_1SDV_20220805T015427_20220805T015452_044411_054CC1_rtc

 'proj:transform': [10.0, 0.0, 519100.0, 0.0, -10.0, 5454150.0, 0.0, 0.0, 1.0],
 'proj:shape': [28793, 21758],
 'proj:bbox': [523650.0, 5237390.0, 804660.0, 5453770.0],

As a consequence it appears proj:bbox is also off (proj:transform is fine):

import pystac
import planetary_computer
import rasterio

stac_item = 'https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-1-rtc/items/S1A_IW_GRDH_1SDV_20220805T015427_20220805T015452_044411_054CC1_rtc'
item = planetary_computer.sign(pystac.read_file(stac_item))
href = item.assets["vv"].href

with rasterio.open(href) as src:
    print(list(src.transform))
    print(src.shape)
    print(list(src.bounds))
    
#[10.0, 0.0, 519100.0, 0.0, -10.0, 5454150.0, 0.0, 0.0, 1.0]
#(21758, 28793)
#[519100.0, 5236570.0, 807030.0, 5454150.0]

possibly related: gjoseph92/stackstac#196

@TomAugspurger
Copy link

Thanks for the report! IIUC, proj:shape should be reversed ([21758, 28793] for this item). What's the expected proj:bbox?

@scottyhq
Copy link
Author

scottyhq commented Jan 9, 2023

@TomAugspurger that's correct. For bbox I expect the proj:xxxx metadata to match rasterio outputs:

Also see:
https://github.com/stac-extensions/projection#projbbox # left, down, right, up

with rasterio.open(url) as src:
    left = src.transform[2]
    top = src.transform[5]
    right, bottom = src.transform * (src.width, src.height)
    
    # equivalent to list(src.bounds)
    bbox = [left, bottom, right, top]

    
# [519100.0, 5236570.0, 807030.0, 5454150.0]

@TomAugspurger
Copy link

We've fixed the proj:shape issue:

In [4]: pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-1-rtc/items/S1A_IW_GRDH_1SDV_20220805T015427_20220805T015452_044411_054CC1_rtc").properties["proj:shape"]
Out[4]: [21758, 28793]

Our partners at Catalyst are also looking into the proj:bbox issue.

@TomAugspurger
Copy link

TomAugspurger commented Feb 7, 2023

The proj:bbox issues has been fixed as well now.

In [1]: import pystac

In [2]: pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-1-rtc/items/S1A_IW_GRDH_1SDV_20220805T015427_20220805T015452_044411_054CC1_rtc").properties["proj:shape"]
Out[2]: [21758, 28793]

In [3]: pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-1-rtc/items/S1A_IW_GRDH_1SDV_20220805T015427_20220805T015452_044411_054CC1_rtc").properties["proj:bbox"]
Out[3]: [519100.0, 5236570.0, 807030.0, 5454150.0]

(previously that was [523650.0, 5237390.0, 804660.0, 5453770.0])

Thanks again for the report and let us know how things go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants