How are calculate_default_transform and aligned_target different?


yon.davies@...
 

Greetings everyone,

I am trying to do reprojection in chunks and have been using rasterio.warp.calculate_default_transform for getting the projected extent and transform of the chunk. However, I noticed rasterio.warp.aligned_target also returns a transform and bounds, but the transform is a bit different from the one returned by calculate_default_transform. The documentation is a little vague – calculate_default_transform: Output dimensions and transform for a reprojection; aligned_target: Aligns target to specified resolution.

Can anyone illuminate this for me? And do you have any insight for which might be better for reprojecting a huge raster in chunks that will eventually be merged later? Thank you.


Sean Gillies
 


Hi Yon,

The intent is that rasterio.warp.reproject, given the values output from calculate_default_transform, will produce a result close to that of GDAL's gdalwarp utility *without* its "-tap" option. And that if you wrap the output of calculate_default_transform with aligned_target, adding a resolution, you will get a result close to that of gdalwarp *with* its "-tap" option.

You can certainly do your own warping in chunks, using Python concurrency features, but you may also rely on GDAL's warper for this. rasterio.warp.reproject will take rasterio datasets as inputs and output and can turn over all the details to GDAL. You can set the number of threads and a limit for memory utilization and GDAL's warper will handle the chunking.

Yours,

On Thu, Jun 10, 2021 at 3:12 PM <yon.davies@...> wrote:
Greetings everyone,

I am trying to do reprojection in chunks and have been using rasterio.warp.calculate_default_transform for getting the projected extent and transform of the chunk. However, I noticed rasterio.warp.aligned_target also returns a transform and bounds, but the transform is a bit different from the one returned by calculate_default_transform. The documentation is a little vague – calculate_default_transform: Output dimensions and transform for a reprojection; aligned_target: Aligns target to specified resolution.

Can anyone illuminate this for me? And do you have any insight for which might be better for reprojecting a huge raster in chunks that will eventually be merged later? Thank you.


--
Sean Gillies