[gdal-dev] gdalinfo and ogrinfo file formats

Even Rouault even.rouault at mines-paris.org
Wed Jan 2 05:41:03 PST 2013


> We're now in the progress of creating C#/WinForms tools on top of these
> functionality to be used in MapWindow. We are going to use *gdalinfo
> --formats* and *gdalinfo --format the_format *to get the relevant data we
> need to create for example a file open box. This works fine since the
> extension can be retrieved from using the --format command.

You don't parse the output of gdalinfo --format, do you ? Please don't do this :
this is really fragile. Imagine what will happen if the output format of the
utility change in some later version ? (We wouldn't do that just for fun, but
relying on that is fragile). Rather look at the source code of gdalinfo (or
actually at GDALGeneralCmdLineProcessor() in gcore/gdal_misc.cpp to C which API
calls are involved.

>
> The same we want to do for the ogr2org.
> *--formats* will give us the available file formats but I can't find a
> command that will give me the expected extension for the file format. I was
> expecting something like *ogrinfo --format "ESRI Shapefile"* that would
> return something like
> ESRI Shapefile format: Format Details:
>   Short Name: sf
>   Long Name: ESRI Shapefile
>   Extension: shp
>   Help Topic: drv_shapefile.html
>
> Am I missing something or isn't this available for ogr?

No, this is not available in OGR. This could be something achievable if the
"Unification of the GDAL and OGR components" mentionned in
http://trac.osgeo.org/gdal/wiki/GDAL20Changes is done, and that OGR drivers can
have metadata.


More information about the gdal-dev mailing list