2

I'm trying to load a GPKG file into QGIS by a VRT file. The vector is inside a ZIP. So I'm using the vsizip. I would like to use just relative paths. But when I try to load it, the new layer comes like an empty table in QGIS. When changed to an absolute path and it worked.

Code with relative path. It doesn't load the vector layer.

<OGRVRTDataSource>
    <OGRVRTLayer name="Layer">
        <SrcDataSource relativeToVRT="1">/vsizip/File_withGeom.zip/VectorFile.gpkg</SrcDataSource>
        <SrcLayer>l</SrcLayer>
    </OGRVRTLayer>
</OGRVRTDataSource>

The code with absolute path. It loads the vector layer.

<OGRVRTDataSource>
    <OGRVRTLayer name="Layer">
        <SrcDataSource relativeToVRT="1">/vsizip/C:/BD_Geo/Vectors/File_withGeom.zip/VectorFile.gpkg</SrcDataSource>
        <SrcLayer>l</SrcLayer>
    </OGRVRTLayer>
</OGRVRTDataSource>

I don't understand why the relative path doesn't work. The code indicates the relative reading form with relativeToVRT="1". And according GDAL documentation, the /vsizip/... is for relative path and /vsizip//... for absolute path.

CONTEXT

This is a simplified code for a study case. The goal is to develop several VRT files that contain a connection (SQL query) between two GPKG. One of them contains the geometry, so it's a big file. The others contain just some attributes. This is a way to save space and to avoid duplications of the geometry. So it should work like a relational database workflow.

2
  • 3
    Evan Rouault (current lead GDAL dev) said no quite a few years ago, perhaps worth asking again on the GDAL mailing list.
    – user2856
    Commented Sep 21, 2021 at 23:42
  • 1
    The native SQLite way would be to use ATTACH DATABASE sqlite.org/lang_attach.html. With GDAL you can attach database via open option PRELUDE_STATEMENTS. I am not sure if is is good idea to use zipped GPKG even it saves space. SQL queries may get very inefficient or then GDAL must create a temporary unzipped database. But interesting trial, go ahead.
    – user30184
    Commented Sep 22, 2021 at 6:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.