[gdal-dev] Creating a blank raster from scratch
Jorge
jorge.arevalo at gmail.com
Mon Feb 2 12:18:46 EST 2009
Hello everybody
I'm creating a blank raster from scratch, to rasterize it later. Ok,
I've read the FAQ:
http://trac.osgeo.org/gdal/wiki/FAQRaster#HowcanIcreateablankrasterbasedonavectorfilesextentsforusewithgdal_rasterize
I've executed this code with no problems in a Mac, with Leopard. I've
used the frameworks at http://www.kyngchaos.com/software:frameworks. The
version of GDAL is 1.6.0, and the numpy version is 1.0.1 Now, I try to
execute the code in another machine, a PC with Suse Linux Enterpise 11.0
for 64bits processors. I've installed gdal and numpy from repositories.
The version of GDAL is 1.6.0, and numpy version is 1.2.1 So, the gdal
versions are the same. But if I open, for example, the file ogr.py in
both systems, are different files. Maybe the Framework I'm using is a
port of GDAL 1.6.0 to Mac with any changes?
And another issue: the code fails in the PC with Suse. The first error is:
src_lyr = src_ds.GetLayerByIndex( index = 0 )
AttributeError: DataSource instance has no attribute 'GetLayerByIndex'
I could solve the problem by changing the call to "GetLayerByIndex(
index = 0 )" for "GetLayer( 0 )". Why is this happening, if the version
of GDAL is 1.6.0 on both systems? Again, I think that maybe the
Framework I'm using is a port of GDAL 1.6.0 to Mac with any changes.
Then, made this change, I get another error, that I couldn't solve yet
(create_raster.py is the name of my file):
File "./create_raster.py", line 112, in ?
dst_ds.GetRasterBand(1).WriteArray( zeros )
File "/usr/lib64/python2.4/site-packages/gdal.py", line 876, in WriteArray
return gdalnumeric.BandWriteArray( self, array, xoff, yoff )
File "/usr/lib64/python2.4/site-packages/gdalnumeric.py", line 193, in
BandWriteArray
datatype = NumericTypeCodeToGDALTypeCode( array.typecode() )
AttributeError: 'numpy.ndarray' object has no attribute 'typecode'
So, basically, the method "BandWriteArray" of gdalnumeric.py is
expecting an object array, with a method named "typecode()", but the
array created with numpy.zeros, don't have this attribute. Am I right?
Then, the fact is that in version 1.0.1 of numpy, the array created with
numpy.zeros has a method named "typecode()", but in version 1.2.1, this
attribute doesn't exist. Do I have to "downgrade" the numpy version from
1.2.1 to 1.0.1 to make the code works in suse? Is there another
solution? Sorry for this kind of questions, but I'm very newbie with Python
Thanks in advance!
Regards
Jorge
More information about the gdal-dev
mailing list