[QGIS-Developer] Why is data source both in layer-tree-layer and in maplayer?

Thomas Larsen Wessel mrvelle at gmail.com
Sun Jul 28 11:04:03 PDT 2024


Thanks :)

I do understand how data is not part of the qgis project file itself.

I chose to add a permanent gpkg layer, by creating a new gpkg file
"foo.gpkg" with one table/layer "mytable". I chose to create the gpkg  in
the same folder as the qgz file. And in fact the file is created in that
location.

But the next time I open the project, it looks in a different folder
(Documents) for foo.gpkg, and therefore cant find it.


On Sun, 28 Jul 2024, 10.25 Vedran Stojnović, <phidrho at gmail.com> wrote:

> Hi Thomas,
>
> GIS stores project files and data files separately.
> Did you create a temporary layer or a permanent one?
> You can also change in Project settings type of stored Path
> (absolute/relative) inside project file.
> --
> - poslano s mobitela -
> Srdačan pozdrav,
> Vedran Stojnović.
>
> On Sat, Jul 27, 2024, 17:52 Thomas Larsen Wessel via QGIS-Developer <
> qgis-developer at lists.osgeo.org> wrote:
>
>> I created an empty qgis project, then chose New GeoPackage Layer, chose a
>> new file "foo.gpkg" and layername "mytable".
>>
>> Everything seems fine. But if I save, and reopen the project it cant find
>> the source. So I inspect the qgz XML and find the source for the layer in
>> two places:
>>
>> ### Layer-Tree-Layer:
>>
>> <layer-tree-layer
>>     id="mytable_d645cad7_6637_434d_9295_dc62a7ff198e"
>>     source="./foo.gpkg|layername=mytable"
>>     legend_split_behavior="0"
>>     name="mytable" expanded="1"
>>     checked="Qt::Checked"
>>     providerKey="ogr"
>>     legend_exp=""
>>     patch_size="-1,-1"
>> >
>>
>> ### MapLayer
>>
>> <projectlayers>
>>     <maplayer (...) >
>>         <id>mytable_d645cad7_6637_434d_9295_dc62a7ff198e</id>
>>
>> <datasource>../../OneDrive/Dokumenter/foo.gpkg|layername=mytable</datasource>
>>         (...)
>>         <layername>foo — mytable</layername>
>>         (...)
>>     </maplayer>
>> </projectlayers>
>>
>>
>> The latter for some reason has a wrong value in datasource. I have no
>> projects or data files in that location, so I guess QGIS somehow defaulted
>> to my users document folder. This seems like some kind of bug.
>>
>> But I wonder, why, in the first place, is datasource in two different
>> places in that file?
>>
>> Running QGIS 3.36.3 on Windows 10.
>>
>> Sincerely, Thomas
>>
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240728/74639d0a/attachment-0001.htm>


More information about the QGIS-Developer mailing list