Skip to main content

Module warp

Module warp 

Source
Expand description

Raster warp — reproject a raster from one CRS to another using geonative-proj for the coordinate transform plus a resampling kernel for the pixel interpolation.

§How it works

For each output pixel:

  1. Compute its world coords in the target CRS via the target tile’s GeoTransform
  2. Reproject those world coords to the source CRS using the Transformer
  3. Project source-CRS world coords back to source pixel coords using the source tile’s GeoTransform
  4. Sample the source band at those (fractional) pixel coords using the chosen kernel

§Memory model

v0.1 takes a single source RasterTile and produces a single output RasterTile. For large inputs the caller should:

  • Read source tiles via RasterLayer::read_tile (cheap with mmap)
  • Warp each tile individually
  • Write to output via the geonative-geotiff writer

For tile-server hot paths (per HTTP request), the future warp_tile_window function reads only the source pixels needed for one output tile — that’s a v0.2 add when streaming warp is needed.

Structs§

WarpOptions

Functions§

compute_target_grid
Compute the world-space bounds in the target CRS that contain the reprojected source extent. Useful for deciding the size of the output RasterTile when the caller wants “warp everything into target CRS at a reasonable resolution.”
warp_tile
Reproject source (with its own CRS + geo-transform) onto the target (crs, geo_transform, width, height). Returns a new RasterTile with the same band descriptors as source but in the target CRS.