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

spatial resolution #104

Open
Sonicious opened this issue Feb 26, 2024 · 6 comments
Open

spatial resolution #104

Sonicious opened this issue Feb 26, 2024 · 6 comments

Comments

@Sonicious
Copy link

When accessing Sentinel 5 (not limited to Sentinel 5 though) data, it is often required to tell the API the exact spatial resolution. There are mapping issues when you access bigger aeas (like completely south america) and you type not the exact resolution.
This leads to two problems:

  • The user needs to find out which is the proper spatial resolution. Maybe adding the default, when it is not given
  • Some satelites have different spatial resolution in lon and lat. Is it possible to set them apart from each other?

Anyway I know SH is not meant to access such big areas to extract such big datacubes. Still there shouldn't be errors, when doing so.

@forman
Copy link
Member

forman commented Feb 26, 2024

Hi @Sonicious, thanks for reporting.

  • The user needs to find out which is the proper spatial resolution. Maybe adding the default, when it is not given

Up to now, most users knew the spatial resolution in advance for their use case, especially when multiple data source are fused together. Unfortunately, we do not maintain a list of spatial default resolutions for the supported datasets. It may also not be obvious, e.g., as you know, Sentinel 2 has 10, 20, and 60m.

  • Some satelites have different spatial resolution in lon and lat. Is it possible to set them apart from each other?

No, this is currently not supported.

However, we see the need to let users choose whether they provide spatial_res or they provide image_size in pixels. In the latter case the spatial resolutions would be derived using the given bbox.

Would you be happy with a new, optional image_size parameter?

@Sonicious
Copy link
Author

Hi @Sonicious, thanks for reporting.

  • The user needs to find out which is the proper spatial resolution. Maybe adding the default, when it is not given

Up to now, most users knew the spatial resolution in advance for their use case, especially when multiple data source are fused together. Unfortunately, we do not maintain a list of spatial default resolutions for the supported datasets. It may also not be obvious, e.g., as you know, Sentinel 2 has 10, 20, and 60m.

I absolutely agree. But the spatial resolution is to be given in parts of degrees, right?

  • Some satelites have different spatial resolution in lon and lat. Is it possible to set them apart from each other?

No, this is currently not supported.

However, we see the need to let users choose whether they provide spatial_res or they provide image_size in pixels. In the latter case the spatial resolutions would be derived using the given bbox.

Would you be happy with a new, optional image_size parameter?

That might be a solution. In this case it works according to the examples in Sentinel Hub. Al this is actually about data which was accessed today to Sentinel 5, TROPOMI. Here we experienced artifacts. According to https://docs.sentinel-hub.com/api/latest/data/sentinel-5p-l2/ the resolution is also not that clear.

I will bring a minimal example tomorrow to show the behaviour.

@forman
Copy link
Member

forman commented Feb 27, 2024

I absolutely agree. But the spatial resolution is to be given in parts of degrees, right?

No. It must be provided in the units of the spatial CRS given by the crs parameter (we need more documentation).
crs defaults to WGS84, therefore spatial_res is in degrees if crs is not provided. If you choose a UTM CRS, units are meters, etc.

I will bring a minimal example tomorrow to show the behaviour.

Ok!

@Sonicious
Copy link
Author

So here is an example which ran in DeepESDL Hub with kernel: deepesdl-xcube-1.3.1.

from xcube.core.store import find_data_store_extensions
from xcube.core.store import get_data_store_params_schema
from xcube.core.store import new_data_store

import IPython.display
from IPython.display import JSON
import shapely.geometry

import os

import xarray as xr
import matplotlib.pyplot as plt 

# setup datastore
store = new_data_store('sentinelhub', 
                       client_id=os.environ["SH_CLIENT_ID"], 
                       client_secret=os.environ["SH_CLIENT_SECRET"], 
                       api_url='https://creodias.sentinel-hub.com', 
                       num_retries=400)
store.describe_data('S5PL2')

# list IDs
# Question here: why there is no sentinel-5p-l2? according to https://docs.sentinel-hub.com/api/latest/data/sentinel-5p-l2/#data-type-identifier-sentinel-5p-l2
store.list_data_ids()

# Region of interest
bbox = [-70, -22, -40, -2]
# Plot the area of interest
IPython.display.GeoJSON(shapely.geometry.box(*bbox).__geo_interface__)
# Let's look for TROPOMI data

ds = store.open_data(
    'S5PL2',
    variable_names=['CO'],
    bbox=bbox,
    spatial_res=0.0025,
    #upsampling='BICUBIC',
    time_range=['2020-06-01', '2020-07-31'],
    time_period='1D'
)
da = ds['CO'];

da.isel(time=10).plot.imshow()
  • First, apparently the white triangles are a problem. They are caused by some spatial resolution resampling. If you change the factor of spatial resolution, the image changes drastically, which I can't explain
  • Additionally, I'm not sure if the bounding box fits the image. looking into the southeast, you see the sea already which is not part of the boundingbox. This might not be true but it looks like this. I have no reference or validation data

Bounding Box:
image

Result:
reuslt

Notebook as zip:
xcube-sh-issue.zip

@forman
Copy link
Member

forman commented Feb 28, 2024

Sorry @Sonicious, xcube-sh does no data processing on its own. All it does is setting up a virtual Zarr mapping so we can create xarray.Dataset objects that perform a deferred loading of data chunks. Loading of chunks boils down to submitting requests to the SentinelHub REST API. Therefore, questions with regards to the geospatial data processing and array contents should go to SentinelHub.

@Sonicious
Copy link
Author

Ok. Thank you very much. Maybe most things will be resolved through a image_size parameter. And rethinking which parameters are stated as required? Also maybe add a documentation about the CRS with an example.
THanks for the support.

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