Module: RemoteTable::Shp
- Defined in:
- lib/remote_table/shp.rb
Overview
Mixed in to process SHP with the georuby library.
Instance Method Summary collapse
Instance Method Details
#_each ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/remote_table/shp.rb', line 4 def _each require 'geo_ruby' shp = Dir[File.join(local_copy.path, '*.shp')].first GeoRuby::Shp4r::ShpFile.open(shp) do |shapefile| shapefile.each do |row| hsh = {} row.data.attributes.each do |name, value| hsh[name] = value end envelope = row.geometry.envelope hsh['center'] = envelope.center hsh['upper_corner_x'] = envelope.upper_corner.x hsh['upper_corner_y'] = envelope.upper_corner.y hsh['lower_corner_x'] = envelope.lower_corner.x hsh['lower_corner_y'] = envelope.lower_corner.y yield hsh end end ensure local_copy.cleanup end |