[gdal-dev] Problems generating float32 geotiffs using OSGEO gdal python bindings

William Hudspeth bhudspeth at edac.unm.edu
Wed Mar 2 12:00:16 EST 2011


Hello,

I am trying to export a numPY float array/matrix to a Lambert Conformal
Geotiff/Float32 image. While the script exports an image, all pixel
values are zero. May numpy array seems to be built correctly, and when I
print it, looks like this...

[[ 0.03678615  0.0390082   0.04026087 ...,  0.03603812  0.03531498
   0.03276101]
[ 0.03677472  0.03901754  0.04030903 ...,  0.03583324  0.0350121
   0.03258276]
[ 0.03676465  0.03900253  0.04031235 ...,  0.03625959  0.03476617
   0.03255093]
..., 
[ 0.03522387  0.03507313  0.03519889 ...,  0.03515329  0.03527898
   0.03535137]
[ 0.03499253  0.03495976  0.03493112 ...,  0.03491645  0.03497614
   0.0349773 ]
[ 0.03486236  0.03487948  0.03492932 ...,  0.03490033  0.03487814
   0.03489009]]
.....

My python code for the export is:

floatNumPyArray=floatNumPyArray(numpy.float)
format="GTiff"
dst_driver=GetDriverByName(format)

srs=osr.SpatialReference()
srs.ImportFromProj4('+proj=lcc +lat_1=33 +lat_2=45 +lat_0=40 +lon_0=-97
+x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')

output=dst_driver.Create(LambertOutput.tif,cols,rows,1,GDT_Float32)
lambert_geotransform=[-1440000,4000,0.0,84000,0.0,-4000]
output.SetGeoTransform(lambert_geotransform)
output.SetProjection(srs.ExportToWkt())
output.GetRasterBand(1).WriteArray(floatNumPyArray)

Thanks in advance for any help...

Bill



More information about the gdal-dev mailing list