Skip to content

Instantly share code, notes, and snippets.

@j08lue
Last active April 24, 2025 20:25
Show Gist options
  • Save j08lue/e792b3c912c33e9191734af7e795b75c to your computer and use it in GitHub Desktop.
Save j08lue/e792b3c912c33e9191734af7e795b75c to your computer and use it in GitHub Desktop.
Reprojecting UKCP 2.2km dataset from rotated pole to regular lat/lon grid using Rasterio 1.4 with src_geoloc_array
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zxdawn
Copy link

zxdawn commented Apr 24, 2025

Thanks for sharing the notebook! I have some hyperspectral satellite L1 data that isn't reprojected yet. The data (long, lat, variables) are in 2d. I suppose it's fine to use this method?

@j08lue
Copy link
Author

j08lue commented Apr 24, 2025

Yes, sounds like it! Pls try and feel free to share here whether it worked out.

You can also use xESMF if that for some unlikely reason better fits your tool stack: https://gist.github.com/j08lue/4952ff9f4a5eb148d198903076664d32

@zxdawn
Copy link

zxdawn commented Apr 24, 2025

Cool! I just tried your code and it works well for my case ;)

As far as I understand, the code reprojects data to your preferred projection by resampling (the default setting is nearest). I also tested the UTM projection, it seems to work well.

@j08lue
Copy link
Author

j08lue commented Apr 24, 2025

Yes, rasterio.warp.calculate_default_transform is for calculating a suitable target transform and shape - could be for any projection you want or you could get this from somewhere else, e.g. a template file - and rasterio.warp.reproject does the actual reprojection, where you can make the usual choices of interpolation methods, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment