Opened 9 years ago
Closed 9 years ago
#5917 closed enhancement (fixed)
OGR option to force named driver only on read
Reported by: | maphew | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | ogr, ogr2ogr |
Cc: |
Description
It would be useful to have OGR use only the named drivers when attempting to read in input source. Basically the inverse of OGR_SKIP
.
The scenario where I want this right now: I'm troubleshooting why some files I have are not recognized or converted by ogr2ogr. Using OGR_SKIP environment variable to leave only 1 or 2 drivers enabled requires a command line string approaching 600 characters, and is easy to write incorrectly (quoted spaces etc.)
In an experiment using python ogr.GetDriverByName(in_format)
it comes to light that at least in one case the instruction is overridden by something else. When in_format is CSV and infile is 'thing.txt' it fails, while infile of 'thing.csv' succeeds. See http://gis.stackexchange.com/questions/141905/force-ogr-to-use-specific-driver-for-input-format
In this we also learned that as of gdal 1.8 CSV:thing.txt
forces using the CSV driver. So somebody encountered the need often enough to program a workaround in the driver itself. This ticket is suggesting this logic be promoted out of single-case use and made available everywhere.
As to syntax, either ARCGEN:thing.asc
or -in_format ARCGEN
both look good to me. Though the latter might be useful for saying "try these drivers in this order".
Change History (2)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Ok, thanks for the info Even. Sounds like this could be closed then. :)
It is possible to restrict the set of allowed drivers in trunk (2.0dev) with GDALOpenEx() / gdal.OpenEx() : http://www.gdal.org/classGDALDataset.html#a9cb8585d0b3c16726b08e25bcc94274a . As raster and vector drivers are unified, this works for both.
Regarding to the issue with CSV, this is a bit different. Only selecting the CSV driver will not make it accept any file. The CSV driver accepts .csv files only. Or you have to really insist with the CSV: syntax. Otherwise it could potentially accept any text file since there's no really distinctive header for a CSV file.