module GDAL::GeoTransform::Extensions
Public Class Methods
included(base)
click to toggle source
@param base [Class,Module]
# File lib/gdal/extensions/geo_transform/extensions.rb, line 10 def self.included(base) base.extend ClassMethods end
Public Instance Methods
to_a()
click to toggle source
All attributes as an Array, in the order the C-Struct describes them:
* x_origin * pixel_width * x_rotation * y_origin * y_rotation * pixel_height
@return [Array]
# File lib/gdal/extensions/geo_transform/extensions.rb, line 85 def to_a [ x_origin, pixel_width, x_rotation, y_origin, y_rotation, pixel_height ] end
world_to_pixel(x_geo, y_geo)
click to toggle source
Calculates the pixel and line location of a geospatial coordinate. Used for converting from world coordinates to to image pixels.
@param x_geo [Number] @param y_geo [Number] @return [Hash{pixel => Integer
, line Integer}]
# File lib/gdal/extensions/geo_transform/extensions.rb, line 39 def world_to_pixel(x_geo, y_geo) pixel = world_to_x_pixel(x_geo) line = world_to_y_pixel(y_geo) { pixel: pixel, line: line } end
world_to_x_pixel(x_geo)
click to toggle source
Calculates the pixel location using the current GeoTransform
and x_geo
coordinate.
@param x_geo [Number] @return [Integer] @raise [GDAL::InvalidGeoTransform] if {GDAL::GeoTransform#pixel_width}
is 0.
# File lib/gdal/extensions/geo_transform/extensions.rb, line 53 def world_to_x_pixel(x_geo) pixel = (x_geo - x_origin) / pixel_width pixel.round.to_i rescue FloatDomainError raise GDAL::InvalidGeoTransform, "Invalid pixel_width (#{pixel_width})" end
world_to_y_pixel(y_geo)
click to toggle source
Calculates the line location using the current GeoTransform
and y_geo
coordinate.
@param y_geo [Number] @return [Integer] @raise [GDAL::InvalidGeoTransform] if {GDAL::GeoTransform#pixel_height}
is 0.
# File lib/gdal/extensions/geo_transform/extensions.rb, line 68 def world_to_y_pixel(y_geo) line = (y_origin - y_geo) / pixel_height line.round.to_i rescue FloatDomainError raise GDAL::InvalidGeoTransform, "Invalid pixel_height (#{pixel_height})" end