odc.geo.overlap.compute_reproject_roi

odc.geo.overlap.compute_reproject_roi(src, dst, ttol=0.05, stol=0.001, padding=None, align=None)[source]

Compute reprojection information.

Given two GeoBoxes find the region within the source GeoBox that overlaps with the destination GeoBox, and also compute the scale factor (>1 means shrink). Scale is chosen such that if you apply it to the source image before reprojecting, then reproject will have roughly no scale component.

So we are breaking up reprojection into two stages:

  1. Scale in the native pixel CRS

  2. Reprojection (possibly non-linear with CRS change)

- src[roi] -> scale      -> reproject -> dst  (using native pixels)
- src(scale)[roi(scale)] -> reproject -> dst  (using overview image)

Here roi is “minimal”, padding is configurable though, so you only read what you need. Also scale can be used to pick the right kind of overview level to read.

Applying reprojection in two steps allows us to use pre-computed overviews, particularly useful when shrink factor is large. But even for data sources without overviews there are advantages for shrinking source image before applying reprojection: mainly quality of the output (reduces aliasing for large shrink factors), improved efficiency of the computation is likely as well.

Also compute and return ROI of the dst geobox that is affected by src.

If padding is None “appropriate” padding will be used depending on the transform between src<>dst:

  • No padding beyond sub-pixel alignment if Scale+Translation

  • 1 pixel source padding in all other cases

Parameters:
  • src (GeoBoxBase) – Geobox of the source image

  • dst (GeoBoxBase) – Geobox of the destination image

  • padding (Optional[int]) – Optional padding in source pixels

  • align (Optional[int]) – Optional pixel alignment in pixels, used on both source and destination.

  • tol – Sub-pixel translation tolerance as pixel fraction.

  • stol (float) – Scale tolerance for pasting

Return type:

ReprojectInfo

Returns:

An instance of ReprojectInfo class.