Was this problem solved?<br>I have tried both <br>dst_ds.GetRasterBand(1).WriteArray(myarray)<br>gdal.Band.WriteArray(dst_ds.GetRasterBand(1), myarray)<br>but my tiff still results in zeros.<br>Any feedback will be greatly appreciated. <br>
<br><div class="gmail_quote">On Fri, Oct 28, 2011 at 7:23 PM, Tom van der Putte <span dir="ltr">&lt;<a href="mailto:tom@vdputte.nl">tom@vdputte.nl</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

Hi List,<br>
<br>
I&#39;m trying to save a numpy array to a GTiff, which should be quite straightforward, considering all the examples available on the web. However, I get an file that is not readable by Qgis, is regarded by ArcMap to have only 0 and gdalinfo displays nothing on the values.<br>

<br>
I start with a ndarray, dtype = int32, shape = ( 10,10). It has integer values between 1 and 10. The code is as follows:<br>
<br>
import numpy as np<br>
from osgeo import gdal<br>
from osgeo import osr<br>
<br>
#np array<br>
a = np.ones((10,10))<br>
<br>
#coord-system<br>
sr_str = &#39;LOCAL_CS[&quot;arbitrary&quot;]&#39;<br>
sr = osr.SpatialReference( sr_str )<br>
<br>
#driver<br>
driver = gdal.GetDriverByName(&quot;GTiff&quot;)<br>
<br>
#dataset<br>
ds = driver.Create(&quot;D:\\temp\\output.tif&quot;, 10, 10, 1, gdal.GDT_Byte)<br>
ds.SetProjection( sr_str )<br>
ds.SetGeoTransform((0, 1, 0,0, 0,1))<br>
<br>
#write and close<br>
ds.GetRasterBand(1).WriteArray(a)<br>
ds = None<br>
<br>
The corresponding gdalinfo is:<br>
*********<br>
Raster dataset parameters:<br>
  Projection: LOCAL_CS[&quot;arbitrary&quot;,UNIT[&quot;metre&quot;,1,AUTHORITY[&quot;EPSG&quot;,&quot;9001&quot;]]]<br>
  RasterCount: 1<br>
  RasterSize (10,10)<br>
Using driver GeoTIFF<br>
  Metadata:<br>
    0:  AREA_OR_POINT=Area<br>
<br>
  Image Structure Metadata:<br>
    0:  INTERLEAVE=BAND<br>
<br>
Corner Coordinates:<br>
  Upper Left (0, 0)<br>
  Lower Left (0, 10)<br>
  Upper Right (10, 0)<br>
  Lower Right (10, 10)<br>
  Center (5, 5)<br>
<br>
Coordinate System is:<br>
LOCAL_CS[&quot;arbitrary&quot;,<br>
    UNIT[&quot;metre&quot;,1,<br>
        AUTHORITY[&quot;EPSG&quot;,&quot;9001&quot;]]]<br>
Band 1 :<br>
   DataType: Byte<br>
   ColorInterpretation: Gray<br>
   Description:<br>
   Size (10,10)<br>
   BlockSize (10,10)<br>
*********<br>
<br>
I have tried both version 1.6.3 (I&#39;m trying to make a Qgis plugin, and thus restricted to 1.6.3) as well as 1.8.1. I have also tried ds = driver.Create(&quot;D:\\temp\\output.tif&quot;, 10, 10, 1, gdal.GDT_Int32), but that didn&#39;t make much difference.<br>

<br>
I tried to make a Surfer grid (GSBG), and this somewhat worked: it gave a nice picture, but the values were off the charts.<br>
<br>
Any clues as to what I&#39;m missing here? Cheers,<span class="HOEnZb"><font color="#888888"><br>
<br>
Tom van der Putte<br>
<br>
 </font></span><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br>