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 Datacube created using Microsoft Planetary Computer #944

Open
cOsprey opened this issue Mar 10, 2024 · 3 comments
Open

Sentinel 1 RTC Datacube created using Microsoft Planetary Computer #944

cOsprey opened this issue Mar 10, 2024 · 3 comments

Comments

@cOsprey
Copy link

cOsprey commented Mar 10, 2024

I am creating a data cube for Sentinel 1 RTC for VV & VH polarization. I am trying to serve it using xcube. I am getting error "ValueError: cannot find any grid mapping in dataset".
The dataset has time,x, and y dimensions. There are other data coordinates also.
Small part of the datacube is here.

Please let me know what I am missing and how to proceed?
Any required parameters for the datacube required to serve?

@TonioF
Copy link
Contributor

TonioF commented Mar 11, 2024

The reference system is not defined correctly in your dataset. Please refer to the cf conventions. The quickest solution to get your dataset supported by xcube is to rename the attribute "crs" to "crs_wkt". Also, in the dataset you have many dimensionless variables which I assume should be attributes.

@cOsprey
Copy link
Author

cOsprey commented Mar 12, 2024

I don't have any attributes in the dataset, I added the crs attribute, defined crs as epsg:32654. But still I am getting same error when I try to run /datasets on the api page, I am getting same error. Is there any example to generate my own cube from an existing xarray dataset ?
I exported the dataset in zarr format and I can serve it in xcube viewer and on the api page also.

@forman
Copy link
Member

forman commented Apr 25, 2024

@cOsprey, your data variables should have an attribute named grid_mapping with the value being the (coordinate) variable that encodes the CRS, usually called crs or spatial_ref.

The variable that encodes the CRS is usually empty or an integer scalar with value zero. Important are only its attributes. They must be encoded using the CF-conventions.

Using pyproj, you can create CF-compliant CRS attributes like so:

import pyproj
import xarray as xr

ds.coords["crs"] = xr.DataArray((), attrs=pyproj.CRS(crs).to_cf())
for var in ds.data_vars.values():
    var.attrs["grid_mapping"] = "crs"    

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

3 participants