Crate mappers_warp

Crate mappers_warp 

Source
Expand description

§Mappers Warp

Very simplistic tool for reprojecting maps, based on the GdalWarp, using mappers for geographic projection.

This tool is effectively a reimplementation of GdalWarp code - all credit for the algorithm creation goes to the GDAL developers.

As you can see, this tool is not very comprehensively documented - if you would like to add something useful to the documentation feel free to open a PR on Github.

§Features

  • multithreading - enables parallel functions for Warper. Requires rayon, but can provide significant performance improvements for some rasters.
  • io - enables support for saving and loading Warper from file. Requires rkyv, but can be useful when you want to initialize Warper ahead-of-time.

§Example

See more usage examples in integration tests.

use mappers::{
    Ellipsoid, projections::{LambertConformalConic, LongitudeLatitude},
};
use mappers_warp::{CubicBSpline, Warper, RasterBoundsDefinition};
use ndarray::Array2;
let src_proj = LongitudeLatitude;
let tgt_proj = LambertConformalConic::builder()
    .ref_lonlat(80., 24.)
    .standard_parallels(12.472955, 35.1728044444444)
    .ellipsoid(Ellipsoid::WGS84)
    .initialize_projection()?;

let source_bounds =
    RasterBoundsDefinition::new((60.00, 68.25), (31.75, 40.0), 0.25, 0.25, src_proj)?;
let target_bounds = RasterBoundsDefinition::new(
    (2_320_000. - 4_000_000., 2_740_000. - 4_000_000.),
    (5_090_000. - 4_000_000., 5_640_000. - 4_000_000.),
    10_000.,
    10_000.,
    tgt_proj,
)?;

let warper = Warper::initialize::<CubicBSpline, _, _>(
    &source_bounds,
    &target_bounds,
)?;

let source_raster = Array2::zeros((34, 34));
let target_raster = warper.warp_ignore_nodata(&source_raster)?;

Structs§

CubicBSpline
B = 1, C = 0
MitchellNetravali
B = 1/3, C = 1/3
RasterBoundsDefinition
RasterBounds follows the meteorological convention on defining raster pixels by midpoints of the grid cells.
Warper
Main struct used for the warp operation

Enums§

WarperError
WarperIOErrorio

Traits§

ResamplingFilter

Functions§

raster_constant_pad
As warper requires the source raster to fully wrap the target raster extent (plus some margin), this function can be used to meet that requirement by adding some padding.