[Gdal-dev] opening dataset of unknown type

Frank Warmerdam warmerdam at pobox.com
Fri Dec 5 13:24:15 EST 2003


Tyler Mitchell wrote:
> 
> 
> 
> I really like how you can program ogr to open a dataset without explicitly
> laying out what type it is.  I assume it tries to open it with a list of
> drivers until it succeeds, or fails altogether.  Is that right?

Tyler,

This is correct.

> Can anyone tell me how you can identify which driver format was successful?
> I'm specifically interested in how to do this in python.  I've got the
> dataset open but don't know, programatically, what type it is.  I see
> ogrinfo returns this information, but I'm not able to figure out how it
> does it.

The short answer, there is no way.

The longer answer is that I have committed changes in the gdal/pymod directory
so that the driver found in ogr.Open() can be captured somewhat like in C or
C++.  You can update from CVS to get this capability.  The new code allows you
to do the following to get the driver name for a dataset.

import ogr

x = ogr.Open( 'openev/polygon.shp' )

print x.GetDriver().GetName()


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    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list