[Gdal-dev] input format

Matt Hanson mhanson at photon.com
Mon Nov 20 14:40:17 EST 2006

In thinking about this more, it would be really easy to specify a format if there was a way to register drivers using text string.   Is there a way to do this?   So, instead of having to call
you call
Easy enough for me to write my own function to do this with all the drivers, but it may be useful enough for other users.
This way you can write an exe that takes in format as a string, and you only Register that format and read in that file.  Follow it up with a RegisterAll() if the program makes use of other formats.    A similar UnregisterDriver(string format) would be userful as well.


From: Frank Warmerdam [mailto:warmerdam at pobox.com]
Sent: Mon 11/20/2006 8:29 PM
To: Matt Hanson
Cc: gdal-dev at lists.maptools.org
Subject: Re: [Gdal-dev] input format

Matt Hanson wrote:
> I apologize for bringing up an issue that I know has been covered/answered
> before, I just can't remember what the answer was!  (and there's no
> web-based search for the list archives).
> How does GDAL decide which format to use to open a file?   In some cases
> there might be multiple methods: such as a raw binary file but also an ENVI
> header file.  Or in our case, we have an ENVI style aux file, but an ENVI
> header may also be present.    I suspect it runs through the list of formats
> and opens it with the first one that works.


Drivers are tried in the order they are registered.

 > Assuming this is so, how can I
> force opening a file with a specific format?

Currently the only way is to unregister all drivers from the driver manager
except the one you want to use (or only register the desired driver on

> In the case of ENVI files (and similar formats that use secondary files) it
> seems that it would make more sense to allow the user to open the hdr file
> rather then the binary file, because while the binary file format could be
> ambiguous, the hdr file would not be.

Perhaps.   But changing something like this would cause a lot of disruption
to existing users.

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 <http://osgeo.org/> 

More information about the Gdal-dev mailing list