datacube.utils.geometry.compute_reproject_roi#

datacube.utils.geometry.compute_reproject_roi(src, dst, tol=0.05, padding=None, align=None)[source]#

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 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

tol – Sub-pixel translation tolerance as a percentage of resolution.

Returns

SimpleNamespace with following fields: .roi_src : (slice, slice) .roi_dst : (slice, slice) .scale : float .scale2 : (sx: float, sy: float) .is_st : True|False .transform : src coord -> dst coord

For scale direction is: “scale > 1 –> shrink src to fit dst”