[Gdal-dev] Python ReadRaster arguments

Howard Butler hobu.inc at gmail.com
Wed May 16 21:34:38 EDT 2007


Yes, I think what happens is the C function needs a string and its  
length, but we use a typemap to take in the Python string and turn it  
into a string and a length.  SWIG generates its docstring using the  
method signature before the typemap is applied, which has buf_len in  
there.

I would also add that I have figured out a slightly messy but useful  
method for extracting the docstrings out of doxygen and applying them  
in the Python SWIG bindings (Python has the best internal doc support  
of the SWIG languages, I think).  I have generated and committed  
these docstrings for OGR, but haven't done so yet for GDAL or OSR.   
So, hopefully in the near future, the docstring for that method will  
just be a copy of the C/C++ docs.  There will obviously still be some  
disconnects, but the docs that have been written are generally more  
useful than having only the default stuff that SWIG generates.

Howard


On May 16, 2007, at 9:03 PM, Frank Warmerdam wrote:

> Gregory, Matthew wrote:
>> Apologies for what is likely a newbie question, but the documentation
>> for gdal.Band.ReadRaster() shows this parameter list:
>> def ReadRaster(*args, **kwargs):
>>         """
>>         ReadRaster(self, int xoff, int yoff, int xsize, int ysize,  
>> int
>> buf_len,             int buf_xsize=0, int buf_ysize=0, int  
>> buf_type=0) -> CPLErr
>>         """
>>         return _gdal.Band_ReadRaster(*args, **kwargs)
>> However, in all the examples I have seen, it looks like the "buf_len"
>> parameter is not given, e.g. (from
>> http://www.gdal.org/gdal_tutorial.html):
>> scanline = band.ReadRaster( 0, 0, band.XSize, 1, band.XSize, 1,
>> GDT_Float32 )
>> Can someone clarify the discrepancy?
>
> Matt,
>
> I'm not sure where these doc strings come from, but I believe that the
> python bindings determine the buf_len internally and so it is not  
> passed
> in as a regular argument (as it would be in C).
>
> Best regards,
> -- 
> --------------------------------------- 
> +--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,  
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | President OSGeo, http:// 
> osgeo.org
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev




More information about the Gdal-dev mailing list