Bug report #9543
VRT vector file don't recognize relative path
|Affected QGIS version:||2.0.1||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||up/downstream|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||18130|
Hi, I build here a vrt on a simple csv file, and QGIS opens it correctly only if I put a absolute file in datasource. Ogrinfo works correctly when using relative paths.. So it is probably related to QGIS method to call GDAL vrt.
<OGRVRTDataSource> <OGRVRTLayer name="cotieres"> <SrcDataSource>V:\\temp_user\\cwbody.csv</SrcDataSource> -- OK <SrcDataSource>cwbody.csv</SrcDataSource> -- NOT WORKING <SrcSQL>select "EU_CD", CAST("LAT" as numeric(8,5)) AS "LAT", CAST("LON" as numeric(8,5)) AS "LON" from cwbody </SrcSQL> <GeometryType>wkbPoint</GeometryType> <LayerSRS>EPSG:4326</LayerSRS> <GeometryField encoding="PointFromColumns" x="LON" y="LAT"/> </OGRVRTLayer> </OGRVRTDataSource>
#4 Updated by Regis Haubourg over 7 years ago
Hi, explicitly setting datasource tag to <SrcDataSource relativeToVRT="1">cwbody.csv</SrcDataSource> does the trick.
Strange behaviour from a user point of view. If behaviour differs between linux and windows, this could be due to bad handling of UNC path in Windows?
#5 Updated by Etienne Tourigny over 7 years ago
Perhaps the difference is that the current directory is not set to that of the .vrt file in windows, whereas it is in linux.
Sorry I cannot help implementing a fix, someone why works with windows builds should do that.
Anyway, there is a simple workaround.
#6 Updated by Etienne Tourigny over 7 years ago
- Operating System deleted (
actually, I was wrong, issue also exists in Linux. I was running qgis from the directory where the .vrt and .csv files reside. If you open from other dir or application launcher, the problem manifests.
On a side note, when you use gdal_translate to create a vrt file, relativeToVRT is set to "1" so I guess the same should be applied to ogr vrt files.
So I'm not sure this should be fixed, but rather relativeToVRT should be set in your file.