Skip to content

edit pr sentinel-1#15

Draft
vincentsarago wants to merge 1 commit intosentinel-1from
vincent/sentinel-1
Draft

edit pr sentinel-1#15
vincentsarago wants to merge 1 commit intosentinel-1from
vincent/sentinel-1

Conversation

@vincentsarago
Copy link
Collaborator

No description provided.

if da.rio.get_gcps():
ds = ds.rename({"ground_range": "x", "azimuth_time": "y"})
ds["x"] = numpy.arange(ds.shape[1])
ds["y"] = numpy.arange(ds.shape[0])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The array in da is still unprojected so it's coordinates are x and y

ds.rio.height,
gcps=gcps,
)
bounds = array_bounds(height, width, transform)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with COGs

from rio_tiler.io import Reader
with Reader("s3://sentinel-s1-l1c/GRD/2024/12/6/IW/DV/S1A_IW_GRDH_1SDV_20241206T180253_20241206T180318_056875_06FBFD_25AD/measurement/iw-vh.tiff") as src:
   print(src.transform)
   print(src.height, src.width)
   print(src.bounds)

| 0.00, 0.00,-2.92|
| 0.00,-0.00, 39.97|
| 0.00, 0.00, 1.00|
18243 31563
(-2.9232683268903976, 38.06529167118216, 0.3728770426105874, 39.97042046045461)


from titiler.eopf.reader import GeoZarrReader
from rasterio.warp import calculate_default_transform
from rasterio.transform import array_bounds

with GeoZarrReader("s3://esa-zarr-sentinel-explorer-fra/tests-output/eopf_geozarr/S1A_IW_GRDH_1SDV_20241206T180253_20241206T180318_056875_06FBFD_25AD.zarr") as src:
   ds = src.datatree["/S01SIWGRD_20241206T180253_0025_A325_25AD_06FBFD_VV/measurements/0/grd"]
   transform, width, height = calculate_default_transform(
         "epsg:4326",
         "epsg:4326",
         ds.shape[1],
         ds.shape[0],
         gcps=ds.rio.get_gcps(),
   )
   bounds = array_bounds(height, width, transform)
   print(transform)
   print(height, width)
   print(bounds)

| 0.00, 0.00,-2.92|
| 0.00,-0.00, 39.97|
| 0.00, 0.00, 1.00|
18243 31563
(-2.923268334017043, 38.065291443928366, 0.372877180534696, 39.970420317038254)

@vincentsarago
Copy link
Collaborator Author

BLOCKED

We're missing some pieces in rioxarray to be able to work with the array and the external gcps. In Rasterio's world we virtually apply the GCPS (reproject) to the dataset using WarpedVRT before doing any read operation so GDAL perform all the transformation between pixel space and the projected space.

Sadly there is no WarpedVRT equivalent for rioxarray.

When we do a Tile request we do:

  • sel: we use clip_bbox to select the indexes corresponding to the input box
  • retroject to the output CRS and given tile shape (256x256px)

https://github.com/cogeotiff/rio-tiler/blob/3a9eefa99f53bfb026f625897ec3f4c401d10af1/rio_tiler/io/xarray.py#L283-L295

I need to check the reproject method to see if we really need to do the sel before the reproject step

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

Successfully merging this pull request may close these issues.

1 participant