Sha256: 29d4d70bac7d8beeab8dd7e765a4d7c85e85a6faec06aafa25512211ee1a5535

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'pry'
require 'ffi-gdal'

include GDAL::Logger
GDAL::Logger.logging_enabled = true

# http://pcjericks.github.io/py-gdalogr-cookbook/vector_layers.html#create-a-new-layer-from-the-extent-of-an-existing-layer

# Get a Layer's Extent
data_source = OGR::DataSource.open('../spec/support/shapefiles/states_21basic/states.shp', 'r')
layer = data_source.layer(0)
extent = layer.extent

# extent = geometry.envelope.world_to_pixels(floyd.geo_transform)
# x_min = extent[:x_origin]
# x_max = extent[:x_max]
# y_min = extent[:y_origin]
# y_max = extent[:y_max]
# log "x_min: #{x_min}"
# log "y_min: #{y_min}"
# log "y_max: #{y_max}"
# log "x_max: #{x_max}"

# Create a polygon from the extent
ring = OGR::Geometry.create(:wkbLinearRing)
ring.add_point(extent.x_min, extent.y_min)
ring.add_point(extent.x_max, extent.y_min)
ring.add_point(extent.x_max, extent.y_max)
ring.add_point(extent.x_min, extent.y_max)
ring.add_point(extent.x_min, extent.y_min)
poly = OGR::Geometry.create(:wkbPolygon)
poly.add_geometry(ring)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta16 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta15 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta14 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta13 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta12 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta11 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta10 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta9 examples/ogr_layer_to_layer.rb
ffi-gdal-1.0.0.beta8 examples/ogr_layer_to_layer.rb