Ruby/GDAL How to open a dataset (1)

I’ll try to post some code snippets on the use of GDAL Ruby bindings. In case you don’t already know there is a bleeding edge gentoo overlay maintained by Kashif at gentoo geo-overlay
I am working on a howto for using that as well to build a gentoo box with some of the latest Open Source Geo-tools.

require 'gdal/gdal'
require 'gdal/gdalconst'
include Gdal
 
file = "./rasterdata.tif"
 
begin
  @dataset = Gdal::Gdal.open(file, Gdalconst::GA_READONLY)
    rescue RuntimeError
      $stderr.print "Gdal failed to open #{file}.\n"
    exit
end
This entry was posted in RubyOnRails. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
blog comments powered by Disqus