[Gdal-dev] Re: your GDAL in C#

Simon Perkins sy at perkins.net
Fri Nov 17 17:05:09 EST 2006


It's been a while since I looked at that code - the standard thing to do 
now is to migrate to using the SWIG generated C# bindings, though those 
are far from complete.

OK, just looked at the code. GDALGetMetadaExt() is the declaration of 
the external (to C#) native GDAL function GDALGetMetadata(), that uses 
raw strings and pointers and so forth. However, to make the function 
easier from C#, the C# GDALGetMetadata() function has an API that uses a 
Dictionary object. The C# GDALGetMetadata() method simply calls 
GDALGetMetadataExt() to do the work, which in turn calls the underlying 
GDAL function.

If you're getting zeros, I would check that you can use GDAL withe the 
C++ API first. Note that most file formats don't support metadata and 
will silently return null pointers. The "domain" flag should generally 
be null - it allows different metadata namespaces to be set up but I 
don't think any formats support that.

BTW, the gdal-dev list is the place to ask questions like this. I've 
copied the list with my answer, for the record.

Cheers,

Sy

MIKAH JAMES TRENT wrote:
> Hi Simon,
> I am working with the UW-Madison ecology labs as a student programmer.  I am trying to use your C# code that you posted on 
>
> http://article.gmane.org/gmane.comp.gis.gdal.devel/6177
>
> to see if we can use or extend your C# wrapper to incorporate GDAL into our own projects (see http://www.landis.forest.wisc.edu).
>
> Could you help me understand what the function "GDALGetMetadataExt" does, or maybe just point me to where it is defined??  The following line of code (from InterOp.cs, in your function GDALGetMetaData):
>
> void** stringList = (void**) GDALGetMetadataExt(hDataset, domain);
>
> always returns 0 for me, even when I am certain the dataset is not empty.  You also have 'domain' set to "null" (in Dataset.cs) when you call GDALGetMetaData.  Could this have something to do with it??
>
> I'm a little new to the whole system, so any help you could provide, even if it's just pointing me somewhere, would be great.  Thanks a bunch,
> -Mikah
>   



More information about the Gdal-dev mailing list