Skip to content

Commit

Permalink
Implemented raster::warp::reproject_into and raster::warp::create_and…
Browse files Browse the repository at this point in the history
…_reproject.
  • Loading branch information
metasim committed Jan 5, 2024
1 parent 924bdbf commit a16e93b
Show file tree
Hide file tree
Showing 22 changed files with 1,037 additions and 58 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

- <https://github.com/georust/gdal/pull/504>

- **Breaking**: Moved `raster::processing::dem` to `raster::dem`
- **Breaking**: Moved `raster::reproject` to `raster::warp::reproject_into` and added more options
- Added `raster::warp::create_and_reproject_image`.

- <https://github.com/georust/gdal/pull/508>

- Added `Feature::unset_field`

- <https://github.com/georust/gdal/pull/503>
Expand Down
Binary file added fixtures/labels-nad.tif
Binary file not shown.
2 changes: 2 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub enum GdalError {
IntConversionError(#[from] TryFromIntError),
#[error("Buffer length {0} does not match raster size {1:?}")]
BufferSizeMismatch(usize, (usize, usize)),
#[error("An unexpected logic error has occurred: {0}")]
UnexpectedLogicError(String),
}

/// A wrapper for [`CPLErr::Type`] that reflects it as an enum
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ mod utils;
pub mod vector;
pub mod version;
pub mod vsi;
pub mod xml;

pub use dataset::Dataset;
pub use geo_transform::{GeoTransform, GeoTransformEx};
Expand Down
1 change: 1 addition & 0 deletions src/raster/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::vec::IntoIter;
#[cfg(feature = "ndarray")]
use ndarray::Array2;

#[cfg_attr(not(feature = "ndarray"), allow(rustdoc::broken_intra_doc_links))]
/// `Buffer<T>` manages cell values in in raster I/O operations.
///
/// It conceptually represents a 2-D array backed by a `Vec<T>` with row-major organization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::num::NonZeroUsize;
use super::options::{common_dem_options, CommonOptions};
use crate::cpl::CslStringList;
use crate::errors;
use crate::raster::processing::dem::DemSlopeAlg;
use crate::raster::dem::DemSlopeAlg;

/// Configuration options for [`aspect()`][super::aspect()].
#[derive(Debug, Clone, Default)]
Expand Down Expand Up @@ -71,7 +71,7 @@ mod tests {
use crate::assert_near;
use crate::cpl::CslStringList;
use crate::errors::Result;
use crate::raster::processing::dem::aspect;
use crate::raster::dem::aspect;
use crate::raster::StatisticsAll;
use crate::test_utils::{fixture, InMemoryFixture};
use crate::Dataset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};

use crate::cpl::CslStringList;
use crate::errors;
use crate::raster::processing::dem::options::common_dem_options;
use crate::raster::dem::options::common_dem_options;

use super::options::CommonOptions;

Expand Down Expand Up @@ -125,7 +125,7 @@ mod tests {
use crate::assert_near;
use crate::cpl::CslStringList;
use crate::errors::Result;
use crate::raster::processing::dem::color_relief;
use crate::raster::dem::color_relief;
use crate::raster::StatisticsAll;
use crate::test_utils::{fixture, InMemoryFixture};
use crate::Dataset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::num::NonZeroUsize;

use crate::cpl::CslStringList;
use crate::errors;
use crate::raster::processing::dem::options::common_dem_options;
use crate::raster::processing::dem::DemSlopeAlg;
use crate::raster::dem::options::common_dem_options;
use crate::raster::dem::DemSlopeAlg;

use super::options::CommonOptions;

Expand Down Expand Up @@ -160,7 +160,7 @@ mod tests {
use crate::assert_near;
use crate::cpl::CslStringList;
use crate::errors::Result;
use crate::raster::processing::dem::hillshade;
use crate::raster::dem::hillshade;
use crate::raster::StatisticsAll;
use crate::test_utils::{fixture, InMemoryFixture};
use crate::Dataset;
Expand Down
14 changes: 7 additions & 7 deletions src/raster/processing/dem/mod.rs → src/raster/dem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod tri;
/// use gdal::Dataset;
/// # fn main() -> gdal::errors::Result<()> {
/// use std::path::Path;
/// use gdal::raster::processing::dem::*;
/// use gdal::raster::dem::*;
/// let ds = Dataset::open("fixtures/dem-hills.tiff")?;
/// let mut opts = AspectOptions::new();
/// opts
Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn aspect<P: AsRef<Path>>(
/// use gdal::Dataset;
/// # fn main() -> gdal::errors::Result<()> {
/// use std::path::Path;
/// use gdal::raster::processing::dem::*;
/// use gdal::raster::dem::*;
/// let ds = Dataset::open("fixtures/dem-hills.tiff")?;
/// let mut opts = ColorReliefOptions::new("fixtures/color-relief.clr");
/// opts.with_alpha(true);
Expand Down Expand Up @@ -189,7 +189,7 @@ pub fn color_relief<P: AsRef<Path>>(
///
/// ```rust, no_run
/// use gdal::Dataset;
/// use gdal::raster::processing::dem::*;
/// use gdal::raster::dem::*;
/// # fn main() -> gdal::errors::Result<()> {
/// use std::path::Path;
/// let ds = Dataset::open("fixtures/dem-hills.tiff")?;
Expand Down Expand Up @@ -247,7 +247,7 @@ pub fn hillshade<P: AsRef<Path>>(
/// # fn main() -> gdal::errors::Result<()> {
/// use gdal::Dataset;
/// use std::path::Path;
/// use gdal::raster::processing::dem::*;
/// use gdal::raster::dem::*;
/// let ds = Dataset::open("fixtures/dem-hills.tiff")?;
/// let roughness_ds = roughness(&ds, Path::new("target/dem-hills-roughness.tiff"), &RoughnessOptions::default())?;
/// let stats = roughness_ds.rasterband(1)?.get_statistics(true, false)?.unwrap();
Expand Down Expand Up @@ -301,7 +301,7 @@ pub fn roughness<P: AsRef<Path>>(
/// # fn main() -> gdal::errors::Result<()> {
/// use std::path::Path;
/// use gdal::Dataset;
/// use gdal::raster::processing::dem::*;
/// use gdal::raster::dem::*;
/// let ds = Dataset::open("fixtures/dem-hills.tiff")?;
/// let mut opts = SlopeOptions::new();
/// opts
Expand Down Expand Up @@ -356,7 +356,7 @@ pub fn slope<P: AsRef<Path>>(
/// # fn main() -> gdal::errors::Result<()> {
/// use std::path::Path;
/// use gdal::Dataset;
/// use gdal::raster::processing::dem::*;
/// use gdal::raster::dem::*;
/// let ds = Dataset::open("fixtures/dem-hills.tiff")?;
/// let tpi_ds = topographic_position_index(&ds, Path::new("target/dem-hills-tpi.tiff"), &TpiOptions::default())?;
/// let stats = tpi_ds.rasterband(1)?.get_statistics(true, false)?.unwrap();
Expand Down Expand Up @@ -404,7 +404,7 @@ pub fn topographic_position_index<P: AsRef<Path>>(
/// # fn main() -> gdal::errors::Result<()> {
/// use std::path::Path;
/// use gdal::Dataset;
/// use gdal::raster::processing::dem::*;
/// use gdal::raster::dem::*;
/// let ds = Dataset::open("fixtures/dem-hills.tiff")?;
/// let mut opts = TriOptions::new();
/// opts.with_algorithm(DemTriAlg::Wilson);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::num::NonZeroUsize;

use crate::cpl::CslStringList;
use crate::errors;
use crate::raster::processing::dem::options::common_dem_options;
use crate::raster::dem::options::common_dem_options;

use super::options::CommonOptions;

Expand Down Expand Up @@ -35,8 +35,8 @@ mod tests {
use crate::assert_near;
use crate::cpl::CslStringList;
use crate::errors::Result;
use crate::raster::processing::dem::roughness;
use crate::raster::processing::dem::roughness::RoughnessOptions;
use crate::raster::dem::roughness;
use crate::raster::dem::roughness::RoughnessOptions;
use crate::raster::StatisticsAll;
use crate::test_utils::{fixture, InMemoryFixture};
use crate::Dataset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::num::NonZeroUsize;

use crate::cpl::CslStringList;
use crate::errors;
use crate::raster::processing::dem::options::common_dem_options;
use crate::raster::processing::dem::DemSlopeAlg;
use crate::raster::dem::options::common_dem_options;
use crate::raster::dem::DemSlopeAlg;

use super::options::CommonOptions;

Expand Down Expand Up @@ -85,7 +85,7 @@ impl SlopeOptions {
mod tests {
use crate::cpl::CslStringList;
use crate::errors::Result;
use crate::raster::processing::dem::slope;
use crate::raster::dem::slope;
use crate::raster::StatisticsAll;
use crate::test_utils::{fixture, InMemoryFixture};
use crate::Dataset;
Expand Down
6 changes: 3 additions & 3 deletions src/raster/processing/dem/tpi.rs → src/raster/dem/tpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::num::NonZeroUsize;

use crate::cpl::CslStringList;
use crate::errors;
use crate::raster::processing::dem::options::common_dem_options;
use crate::raster::dem::options::common_dem_options;

use super::options::CommonOptions;

Expand Down Expand Up @@ -34,8 +34,8 @@ mod tests {
use crate::assert_near;
use crate::cpl::CslStringList;
use crate::errors::Result;
use crate::raster::processing::dem::topographic_position_index;
use crate::raster::processing::dem::tpi::TpiOptions;
use crate::raster::dem::topographic_position_index;
use crate::raster::dem::tpi::TpiOptions;
use crate::raster::StatisticsAll;
use crate::test_utils::{fixture, InMemoryFixture};
use crate::Dataset;
Expand Down
4 changes: 2 additions & 2 deletions src/raster/processing/dem/tri.rs → src/raster/dem/tri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::num::NonZeroUsize;

use crate::cpl::CslStringList;
use crate::errors;
use crate::raster::processing::dem::options::common_dem_options;
use crate::raster::dem::options::common_dem_options;

use super::options::CommonOptions;

Expand Down Expand Up @@ -80,7 +80,7 @@ impl DemTriAlg {
mod tests {
use crate::assert_near;
use crate::errors::Result;
use crate::raster::processing::dem::terrain_ruggedness_index;
use crate::raster::dem::terrain_ruggedness_index;
use crate::raster::StatisticsAll;
use crate::test_utils::{fixture, InMemoryFixture};
use crate::Dataset;
Expand Down
5 changes: 2 additions & 3 deletions src/raster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,17 @@ pub use rasterband::{
};
pub use rasterize::{rasterize, BurnSource, MergeAlgorithm, OptimizeMode, RasterizeOptions};
pub use types::{AdjustedValue, GdalDataType, GdalType};
pub use warp::reproject;

mod buffer;
pub mod dem;
#[cfg(all(major_ge_3, minor_ge_1))]
mod mdarray;
pub mod processing;
mod rasterband;
mod rasterize;
#[cfg(test)]
mod tests;
mod types;
mod warp;
pub mod warp;

/// Key/value pair for passing driver-specific creation options to
/// [`Driver::create_with_band_type_wth_options`](crate::Driver::create_with_band_type_with_options`).
Expand Down
3 changes: 0 additions & 3 deletions src/raster/processing/mod.rs

This file was deleted.

27 changes: 0 additions & 27 deletions src/raster/warp.rs

This file was deleted.

Loading

0 comments on commit a16e93b

Please sign in to comment.