[Gdal-dev] How can I initialize the GDALDataset structures withoutcalling GDALOpen

Joaquim Luis jluis at ualg.pt
Thu Mar 25 10:17:09 EST 2004


Frank Warmerdam wrote:

> I'm not exactly clear on what you are doing.  Are you wanting to do a memory
> to memory warp?  A memory to disk write?
>
> I think you should read over the information about the "In Memory" format.
> This is a GDAL driver that allows you to describe an array in memory as a
> GDAL dataset.  This is often used as a pre-step to using GDALCreateCopy()
> to create a copy of the image on disk.
>
>    http://www.remotesensing.org/gdal/frmt_mem.html
>
> Basically, you will constuct an esoteric string "dataset name" describing
> the memory array, and then call GDALOpen() on that to create a dataset handle
> for a memory array.  Then you can attach metadata, georeferencing and so on
> normally and use the dataset handle with other GDAL functions like the warper
> or GDALCreateCopy().
>
> Once you have made an effort at this feel free to ask for more detail on parts
> that are giving you problems ... but some more specific context would be helpful.
>

Frank,
Thanks for your answer. I'll try to be more specific.
Matlab provides a mechanism by which we can write interfaces between existing C code
and the Matlab engine.
Namely, a function called the Matlab gateway has the following form
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
To simplify lets just say that nrhs is the number of input arguments and prhs contains

whatever data we want to transmit to this function.
With this I can transmit, for example, a 3D matrix containing an image data (3D to
account
for the number of Bands) and other pertinent information like pixel size,
georeferencing information, etc...

Its now that GDAL comes in. So I want to do either a memory to memory warp (case in
which
the result will be returned to my Matlab code) or a memory to disk write (save the
transformed
data into a file).
I already used this facility to write a "gdalread" and it's a kind of "gdalwrite" that
I'm after.

I was not aware on the existence of the MEM driver. The man pages I have on my
computer are
from the OpenEV_FW distribution, and they do not refer that driver. It would be nice
if the most
updated html man pages were included with the GDAL distro (the html directory in it is
empty).

Now, I'm willing to make all efforts I can, but I need an extra help for starting. I
am not a c++
programer and I got confused on how to use the MEM driver. You mentioned the need to
"construct an esoteric string "dataset name" describing the memory array"
but I don't see how I can do it. The MEM example in the page you point me to does not
seam
to return any "dataset name" (but as I said I don't know c++). And because GDALOpen
needs
a dataset name in input I am stuck.

If you want to see what is this for, please take a look at
w3.ualg.pt/~jluis/Mirone

Thanks

Joaquim




More information about the Gdal-dev mailing list