title: How to explicitly close datasets in GDAL ruby binding?
body: <p>I am using <a href="https://gdal.org/" rel="nofollow noreferrer">GDAL</a> 1.7.1 from ruby1.9 to generate GeoTIFF files. In the <a href="https://gdal.org/tutorials/raster_api_tut.html" rel="nofollow noreferrer">tutorial</a> they recommend to use GDALClose() to close the datasets and flush any remaining content to the filesystem. The same happens in the destructor for the dataset. The problem is that the ruby bindings rely on this destructor mechanism to close the dataset, and I need the result of the file already in the process that generates it. Since ruby is garbage collected, it seems I can not reliably close my files, without exiting the ruby process. For now I patched my version of GDAL to support the GDALClose method, but this doesn't seem to be a good long term solution.</p>
  <pre><code>require 'gdal/gdal'
  
  [...]
  
  # open the driver for geotiff format
  driver = Gdal::Gdal.get_driver_by_name('GTiff')
  # create a new file
  target_map = driver.create(output_path,
                  xsize,
                  ysize, 3,
                  Gdal::Gdalconst::GDT_UINT16, [&quot;PHOTOMETRIC=RGB&quot;])
  
  # write band data
  3.times do |i|
      band = target_map.band(i + 1)
      target_map.write_band(i + 1, mapped_data)
  end
  
  # now I would like to use the file in output_path, but at this point 
  # large parts of the data still resides in memory it seems until 
  # target_map is destroyed
  
  file = File.open( output_path, &quot;r&quot; )
  
  [...]
  </code></pre>
  <p>Is there something in either ruby or swig to force the destructor call, that I may have overlooked?</p>