Module: GDAL::Dataset::WarpMethods

Included in:
GDAL::Dataset
Defined in:
lib/gdal/dataset/warp_methods.rb

Overview

Methods used for warping; most taken from gdalwarper.h.

Instance Method Summary collapse

Instance Method Details

#create_and_reproject_image(destination_file_name, resample_algorithm, destination_projection, destination_driver, creation_options: {}, warp_memory_limit: 0.0, max_error: 0.0, progress_function: nil, progress_arg: nil, warp_options: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists

Parameters:

  • destination_file_name (String)

    Path to the output dataset.

  • resample_algorithm (Symbol)

    One from FFI::GDAL::Warper::GDALResampleAlg.

  • destination_projection (String)

    WKT of the projection to be used for the destination dataset.

  • destination_driver (GDAL::Driver)

    Driver to use for the destination dataset.

  • creation_options (Hash) (defaults to: {})

    Driver-specific options to use during creation.

  • warp_memory_limit (Float) (defaults to: 0.0)

    The amount of memory (in bytes) the API is allowed to use for caching. This is in addition to the amount of memory already allocated for caching (using GDALSetCacheMax). 0.0 uses default settings.

  • max_error (Float) (defaults to: 0.0)

    Maximum error, measured in input pixels that is allowed in approximating the transformation. Defaults to 0.0.

  • progress_function (Proc, FFI::GDAL::GDAL::GDALProgressFunc) (defaults to: nil)

    A callback for reporting progress.

  • progress_arg (FFI::Pointer) (defaults to: nil)

    Argument to be passed to progress_function.

  • warp_options (GDAL::WarpOptions) (defaults to: nil)

    Warp options, normally empty.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/gdal/dataset/warp_methods.rb', line 59

def create_and_reproject_image(destination_file_name, resample_algorithm, destination_projection,
  destination_driver, creation_options: {},
  warp_memory_limit: 0.0, max_error: 0.0,
  progress_function: nil, progress_arg: nil,
  warp_options: nil)
  creation_options_ptr = GDAL::Options.pointer(creation_options)
  warp_options_struct = warp_options&.c_struct

  FFI::GDAL::Warper.GDALCreateAndReprojectImage(
    @c_pointer,                           # hSrcDS
    nil,                                  # pszSrcWKT
    destination_file_name,                # pszDstFilename
    destination_projection,               # pszDstWKT
    destination_driver.c_pointer,         # hDstDriver
    creation_options_ptr,                 # papszCreateOptions
    resample_algorithm,                   # eResampleAlg
    warp_memory_limit,                    # dfWarpMemoryLimit
    max_error,                            # dfMaxError
    progress_function,                    # pfnProgress
    progress_arg,                         # pProgressArg
    warp_options_struct                   # psOptions
  )
end

#reproject_image(destination_dataset, resample_algorithm, destination_projection: nil, warp_memory_limit: 0.0, max_error: 0.0, progress_function: nil, progress_arg: nil, warp_options: nil) ⇒ Object

Parameters:

  • destination_dataset (GDAL::Dataset)
  • resample_algorithm (Symbol)

    One from FFI::GDAL::Warper::GDALResampleAlg.

  • destination_projection (String) (defaults to: nil)
  • warp_memory_limit (Float) (defaults to: 0.0)

    The amount of memory (in bytes) the API is allowed to use for caching. This is in addition to the amount of memory already allocated for caching (using GDALSetCacheMax). 0.0 uses default settings.

  • max_error (Float) (defaults to: 0.0)

    Maximum error, measured in input pixels that is allowed in approximating the transformation. Defaults to 0.0.

  • progress_function (Proc, FFI::GDAL::GDAL::GDALProgressFunc) (defaults to: nil)

    A callback for reporting progress.

  • progress_arg (FFI::Pointer) (defaults to: nil)

    Argument to be passed to progress_function.

  • warp_options (GDAL::WarpOptions) (defaults to: nil)

    Warp options, normally empty.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gdal/dataset/warp_methods.rb', line 21

def reproject_image(destination_dataset, resample_algorithm, destination_projection: nil,
  warp_memory_limit: 0.0, max_error: 0.0, progress_function: nil, progress_arg: nil, warp_options: nil)
  warp_options_struct = warp_options&.c_struct

  FFI::GDAL::Warper.GDALReprojectImage(
    @c_pointer,                           # hSrcDS
    nil,                                  # pszSrcWKT
    destination_dataset.c_pointer,        # hDstDS
    destination_projection,               # pszDstWKT
    resample_algorithm,                   # eResampleAlg
    warp_memory_limit,                    # dfWarpMemoryLimit
    max_error,                            # dfMaxError
    progress_function,                    # pfnProgress
    progress_arg,                         # pProgressArg
    warp_options_struct                   # psOptions
  )
end