Module: GDAL::GeoTransform::Extensions::ClassMethods

Defined in:
lib/gdal/extensions/geo_transform/extensions.rb

Instance Method Summary collapse

Instance Method Details

#new_from_envelope(envelope, raster_width, raster_height) ⇒ Object

Builds a GeoTransform from the x and y mins and maxes from the envelope. Uses raster_width and raster_height to calculate the pixel dimensions. Assumes north-up.

Parameters:



22
23
24
25
26
27
28
29
30
# File 'lib/gdal/extensions/geo_transform/extensions.rb', line 22

def new_from_envelope(envelope, raster_width, raster_height)
  gt = GDAL::GeoTransform.new
  gt.x_origin = envelope.x_min
  gt.y_origin = envelope.y_min
  gt.pixel_width = envelope.x_size / raster_width
  gt.pixel_height = envelope.y_size / raster_height

  gt
end