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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>