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

bug in `xcube.core.resampling.resample_in_space #1016

Closed
konstntokas opened this issue Jun 17, 2024 · 1 comment
Closed

bug in `xcube.core.resampling.resample_in_space #1016

konstntokas opened this issue Jun 17, 2024 · 1 comment

Comments

@konstntokas
Copy link
Contributor

Describe the bug
When trying to use resample_in_space to convert Sentinel-2 data from EPSG:4326 to EPGS:3035 a ValueError: new_grid_mapping_from_dataset occurs when trying to get a GridMappingfrom dataset in `xcube.core.resampling.resample_in_space()

To Reproduce
The following script, produces the error:

from xcube.core.store import new_data_store
from xcube.core.resampling import resample_in_space
import pyproj


# create sentinelhub datastore
store = new_data_store("sentinelhub")

# selection parameters
data_id = "S2L2A"
bbox = [9.6, 47.4, 9.8, 47.6]
tile_size = [1024, 1024]
time_range = ("2020-06-01", "2020-07-01")
variable_names = ["B03", "B04"]

# get data in EPSG:4326
spatial_res = 0.00018
ds_4326 = store.open_data(
    data_id,
    variable_names=variable_names,
    bbox=bbox,
    spatial_res=spatial_res,
    time_range=time_range,
    tile_size=tile_size,
)
print(ds_4326)

# get data in EPSG:3035
transformer = pyproj.Transformer.from_crs("EPSG:4326", "EPSG:3035", always_xy=True)
pmin = transformer.transform(bbox[0], bbox[1])
pmax = transformer.transform(bbox[2], bbox[3])
bbox_3035 = [pmin[0], pmin[1], pmax[0], pmax[1]]
spatial_res_3035 = 20
ds_3035 = store.open_data(
    data_id,
    variable_names=variable_names,
    bbox=bbox_3035,
    spatial_res=spatial_res_3035,
    time_range=time_range,
    tile_size=tile_size,
    crs="EPSG:3035",
)
print(ds_3035)

# resample the data
ds_resample = resample_in_space(ds_4326.isel(time=4), ref_ds=ds_3035.isel(time=4))
print(ds_resample)

Expected behavior
The function should convert the projection and resample to the grid mapping of the reference dataset.

@konstntokas
Copy link
Contributor Author

This now works since #1082

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

1 participant