title: How to write manipulated raster values to ASCII grid with GDAL?
body: <p>I am trying to manipulate raster values in a grid (ASCII Grid) with GDAL. But before proceeding with this, I have trouble writing the new values into the file. I get these error messages when slopeband.WriteArray(s) is called.</p>
  
  <p>ERROR 6: slope.asc, band 1: WriteBlock() not supported for this dataset.</p>
  
  <p>ERROR 1: slope.asc, band 1: An error occured while writing a dirty block</p>
  
  <p>I'm sorry if this is very basic, but I'm still new to python and GDAL in particular. I use GDAL 1.9.0 on Mac OS X 10.6.8 and Python 2.7. Thank you!</p>
  
  <pre><code>import numpy
  import gdal
  import gdalconst
  
  dgm = gdal.Open("DGM_10_MR.asc", gdalconst.GA_ReadOnly)
  driver = dgm.GetDriver()
  geotransform = dgm.GetGeoTransform()
  band = dgm.GetRasterBand(1)
  data = band.ReadAsArray()
  
  cols = dgm.RasterXSize
  rows = dgm.RasterYSize
  slope = driver.CreateCopy("slope.asc", dgm)
  slope = None
  dgm = None
  slope = gdal.Open("slope.asc", gdalconst.GA_Update)
  slope.SetGeoTransform(geotransform)
  slopeband = slope.GetRasterBand(1)
  s = slopeband.ReadAsArray()
  
  for y in range(rows):
      for x in range(cols):
          s[y, x] = 0.0
  
  slopeband.WriteArray(s)
  slopeband.FlushCache()
  del s
  
  dgm = None
  slope = None
  print "done"
  </code></pre>