1

I am working with Sentinel 3 SLSTR data which comes in netCDF file format. The file contains 11 bands: S1-S6 (500 m resolution) and S7-S9 and F1 & F2 (1000 m resolution). S1-S6 contains radiance values and S7-S9 contains brightness temperature values. Right now, I want to resample my S7-S9 band to 500 m resolution to match the resolution of S1-S6 bands.

I am using xarray to read the netCDF files. There is a function xarray.Dataset.resample() but the documentation says that it resample to a new temporal resolution.

I also tried to resample using gdal but couldn't get any result.

import gdal
import xarray as xr
import matplotlib.pyplot as plt

data = xr.open_dataset('S7_BT_in.nc')          # one of the files in 1000 m resolution
geo = xr.open_dataset(path+'geodetic_an.nc')   # file containing the geodetic values


ds = data['S7_BT_in']                # fetching variable I need to work on
lat = geo['latitude_an']             # fetching latitude values
lon = geo['longitude_an']            # fetching longitude values



#assigning latitude and longitude values to the coordinates of ds 
ds = ds.assign_coords(coords = {'Latitude': lat, 'Longitude': lon})    

x = gdal.Open('ds')             # Opening the netCDF file using gdal


# resampling the data to 500 m resolution
xreproj = gdal.Warp('resampled.nc', x, xRes = 500, yRes = 500)

This is the error I am getting:

SystemError: <built-in function wrapper_GDALWarpDestName> returned NULL without setting an error.

I also tried opening the file directly using gdal but still getting the same error.

  • Hi, I think your problem is more likely to be an interpolation problem than a resampling one. Maybe the `interp` method woud suit your need ? – cyril Apr 06 '22 at 09:01
  • There is something that is amiss with your netCDF file, can you post the GDAL CLI error and the output of `gdalinfo` of your file. Also, you don't need the very complex `Warp` operation to resample - resampling can even be performed on the fly when reading. – mmomtchev Apr 11 '22 at 16:41

0 Answers0