2

I'm trying to read a tile from the Sentinel1 SAR data collection. I'm using rioxarray to open the .tiff data file.

rioxarray.open_rasterio(
                path_to_data,
                overview_level=2,
                parse_coordinates=True,
                ).astype(float).squeeze()

When the data is loaded I print it in a notebook cell and get it's size and type:

xarray.DataArray y:4172 x:6475

I want to only focus on an area of interest here and use coordinates of an area as indices. However, the array only accepts ints and is not indexed based on coordinates. Is there any way to use coordinates to access the DataArray? My goal is to only keep the area of interest not the whole tile, how can I do so?

2
  • Are you having difficulty turning world coordinates (lat/lon or Easting/Northing) into pixel space (row, column) or is it you don't know how to index your DataArray with the row, column index? Commented Feb 23, 2023 at 5:19
  • @MichaelStimson both! I was expecting to be able to index the DataArray using lat/lon but it seems that I have to transform the lat/lon to pixel indices using height/width and resolution.
    – Sina
    Commented Feb 25, 2023 at 5:05

1 Answer 1

3

Note that your Sentinel-1 data isn't geocoded or orthorectified, so your data shouldn't have any geographical information.

You could use higher-level libraries to manage this, like EOReader or xarray-sentinel.

Here is the notebook for window-reading satellite data with EOReader. The example is about Landsat-8 but should also work with Sentinel-1.

Disclaimer: I am the maintainer of EOReader

4
  • I couldn't get the EOReader to work. My data is in .tif format and the Reader class reads compressed SAFE files. I get the data from Microsoft planetary computer.
    – Sina
    Commented Feb 25, 2023 at 5:02
  • You could use the Custom Product, a notebook exists to help you : eoreader.readthedocs.io/en/v0.19.2/notebooks/custom.html However I never tested it on MPC, so I would be glad to have any feedback
    – remi.braun
    Commented Feb 25, 2023 at 13:51
  • It seems that the data that I have has GCPS and it's not projected. I had look at EOReader's reader class and it doesn't do projection. Do you know how I can project the data?
    – Sina
    Commented Feb 25, 2023 at 18:14
  • Ha, yes EOReader can only orthorectify raw data (i.e. .SAFE folder for Sentinel-1)... xarray-sentinel doesn't handle this case ? Otherwise, you should reproject it with rasterio/rioxarray using the gcps...
    – remi.braun
    Commented Feb 27, 2023 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.