Sha256: eb2792bdeb889d1a780af846dfeb5aa7e1aa4d338468a1024ca907ae8cb4f564
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true require "bundler/setup" require "ffi-gdal" include GDAL::Logger # rubocop:disable Style/MixinUsage 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 # 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ffi-gdal-1.1.0 | examples/ogr_layer_to_layer.rb |
ffi-gdal-1.0.4 | examples/ogr_layer_to_layer.rb |
ffi-gdal-1.0.3 | examples/ogr_layer_to_layer.rb |