Regridding data for clipping to shapefile - [Sentinel-3 L2 LST // SLSTR Instrument]

Hi There,

First time posting for help on the Pangeo community, and pretty new to the geospatial domain.

In a Nutshel

In few words : from my initial objective of cliping raster/xarray data to a polygon/shapefile, I ended up looking for information on regridding/interpolation.

My Data

The data product I’m using is from Sentinel-3, Level 2 Land Surface Temperature (SLSTR).
I preprocessed the content of one zip and ended up with this shape of data:


I get that what I’m getting from this product, is a grid corresponding to the satellite swath “scatter plots”, as displayed below:

In the many examples I’ve encountered, dimensions and coordinates are usually similar, and 1D.
So, I’ve come to the point where I understand that further processing would need a ‘regridding’, otherwise said ‘interpolation’ on a regularly spaced grid (which is not my case at the moment).


Then my questions are:

  • considering the shape of the data I’m dealing with: what would you recommend me to use (package, interpolation algo, projection grid, …)

Keep in mind that I might have to:

  • merge multiple swath products to build a global map (in the future),
  • and that my objetive is to be able to clip this xarray to a shapefile to apply specific processing on measures from the shapefile’s area.

Thank you very much in advance for your help.

PS : I’ve requested some help on another forum. You might get additional information from there:
Clip Sentinel-3 LST raster to polygon shapefile - s3tbx - STEP Forum

You might want to look at xESMF. xESMF: Universal Regridder for Geospatial Data — xESMF 0.3.0 documentation

Could try regionmask

A question is what type/why are you doing regridding…then people might have specific suggestions?

Hi Mathieu,
not sure it answsers your question but I have put in place those jupyter notebooks about

  • how to handle shapefiles and display the polygon with cartopy ?
  • how to generate a polygon shapefile from boundaries definition ?
  • how to mask (clip) an xarray dataset (from netcdf file) with a polygon shapefile ?

it is not pangeo-oriented so there are certainly more elegant approach using pangeo…

anyway, here is the git repository

Alright, thanks you all for your contributions.
Wasn’t available so…sorry for the delay.
Here are my updates.


You might want to look at xESMF

I’ve found some packages/tools that might be relevant but still haven’t take the time to benchmark which one might be the most appropriate between:

  • xESMF
  • pyresample
  • pangeo-pyinterp


Could try regionmask

I bumped into this but it doesn’t seem appropriate since it corresponds to “administrative-clipping” (if I may say), while I’m trying to subset my raster with very specific polygons.
Am I right ?

I’m fairly new to this domain, so I’ll try to answer your question as precisely and synthetically as possible:

My initial goal there was to “clip” my non lat/long-gridded xarray to a polygon/shapefile.
The tools/scripts I found looked quite easy but always seemed to be using georeference (lat/lon) dimensional raster…

That’s when I thought I had to regrid/reproject my raster into a georeferenced lat/lon dimension raster before applying those tricks.

Feel free to advice for some more relevant process to apply to meet my initial goal.


I have put in place those jupyter notebooks …

Thanks, I’ll have a look :wink:

Yes, often examples use geojson - which is going to be latlon generally speaking.

You clip data in a projection you have with vector data in the projection you have - so can be other way around more easily.

Not sure the following rephrase might help, but at least it’s helping me try to focus on what my main question is.

At the moment, and in order to perform later regridding, I feel like what I’m trying to ask help for is to interpolate an unstructured/irregularly spaced scatter plot latlon grid into a structured/regularly spaced one.

FYI, I’ve also been adviced to look into pangeo-pyinterp documentation, on the specific case of ‘unstructured grid’:

Hi there,

Just wanted to share that I’ve been able to “regrid” my raster using the pangeo-pyinterp package used in the previously shared links.

In order for others to enjoy a smoother path to achieving regridding, I strongly recommend to have a look at those 2 links:

If I had to summarize the process in my own words, it would be:

  • build your initial dataset, defining your lat/lon dataarrays as coordinates (depending on the initial x/y grids),
  • define the mesh ‘nest’ through the use of pyinterp.RTree() and mesh.packing,
  • define the new grid you want your new data to be regridded in through the use of np.meshgrid,
  • then use, for example (and choosing wisely :smiley: ), mesh.inverse_distance_weighting or mesh.radial_basis_function to interpolate the initial gridded data in a new data.

Remember, I had to regrid my data because the initial ones corresponded to an irregular grid regarding corresponding georeferenced coordinates.
Your case might be different, but I hope somebody out here will benefit from this exchange.

Thanks again to all of you contributors.

PS : I would like to flag this issue as SOLVED but…doesn’t seem to find a way to do it…any help ?

1 Like