Handle local layers in resources folder when project saved in PostgreSQL

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Handle local layers in resources folder when project saved in PostgreSQL

Yann Voté
Hi all,

I can't find a solution to the following issue, or a way to work around
it: I have created a project with some PostgreSQL layers to edit and
some raster layers on local filesystem. I work on a Linux computer and
have put the local layers into the pkg data path resources folder
(/usr/share/qgis/resources/local/raster.gpkg).

I have also saved the project into PostgreSQL so that it can be shared
easily. Other users work on Windows computers and have the same rasters
under pkg data path resources folder
(C:/PROGRAM~1/QGIS3~1.8/apps/qgis/resources/local/raster.gpkg). But when
they open the project, Postgis layers are loaded fine, but QGIS says
that raster.gpkg cannot be found under the /usr/share/... path.

I would expect that layers in the pkg data path resources folder are
saved with the inbuilt: prefix, but in fact they are not. Moreover, it
seems that one cannot select "Relative" for saving layer paths, in
project properties, when project is saved to PostgreSQL. Looks sensible
(what is the relative path to a PostgreSQL table ?), but then what can I
do to share a PostgreSQL project with local layers ?

We all use QGIS 3.8.3.

Thank you for any advice !

Cheers

Yann
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Handle local layers in resources folder when project saved in PostgreSQL

Alessandro Pasotti-2


On Thu, Dec 5, 2019 at 11:58 AM Yann Voté <[hidden email]> wrote:
Hi all,

I can't find a solution to the following issue, or a way to work around
it: I have created a project with some PostgreSQL layers to edit and
some raster layers on local filesystem. I work on a Linux computer and
have put the local layers into the pkg data path resources folder
(/usr/share/qgis/resources/local/raster.gpkg).


Sorry but this is not a good idea, that path is usually not user-writeable and should not be used to store any user related information.

But if I understand correctly what you were trying to do I'm afraid there is not a solution: the concept of "relative path" means relative to the project's storage path but that path does not make any sense in case of a POSTGRES storage (because POSTGRES is not a local filesystem-based DB in the same sense as GPKG or SPATIALITE are), so your file-system based asset paths are not (and cannot be) converted to relative paths because there is no project path we can relate to.

This makes portability an issue if the project has filesystem-based layers (rasters in your case).

There is no solution I'm aware of, storing rasters into PG is also not a viable option at the moment because support is currently buggy (see: https://github.com/qgis/QGIS/issues/30392).

Cheers

I have also saved the project into PostgreSQL so that it can be shared
easily. Other users work on Windows computers and have the same rasters
under pkg data path resources folder
(C:/PROGRAM~1/QGIS3~1.8/apps/qgis/resources/local/raster.gpkg). But when
they open the project, Postgis layers are loaded fine, but QGIS says
that raster.gpkg cannot be found under the /usr/share/... path.

I would expect that layers in the pkg data path resources folder are
saved with the inbuilt: prefix, but in fact they are not. Moreover, it
seems that one cannot select "Relative" for saving layer paths, in
project properties, when project is saved to PostgreSQL. Looks sensible
(what is the relative path to a PostgreSQL table ?), but then what can I
do to share a PostgreSQL project with local layers ?

We all use QGIS 3.8.3.

Thank you for any advice !

Cheers

Yann
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


--
Alessandro Pasotti
w3:   www.itopen.it

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Handle local layers in resources folder when project saved in PostgreSQL

Raymond Nijssen
Not sure if it is a good idea, but you might find a workaround using a
startup script or plugin containing this functionality:

https://qgis.org/pyqgis/master_temp/core/QgsPathResolver.html

I guess it will be too tricky/hacky but I hope it helps you.

Raymond


On 05-12-2019 12:18, Alessandro Pasotti wrote:

>
>
> On Thu, Dec 5, 2019 at 11:58 AM Yann Voté <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi all,
>
>     I can't find a solution to the following issue, or a way to work around
>     it: I have created a project with some PostgreSQL layers to edit and
>     some raster layers on local filesystem. I work on a Linux computer and
>     have put the local layers into the pkg data path resources folder
>     (/usr/share/qgis/resources/local/raster.gpkg).
>
>
> Sorry but this is not a good idea, that path is usually not
> user-writeable and should not be used to store any user related information.
>
> But if I understand correctly what you were trying to do I'm afraid
> there is not a solution: the concept of "relative path" means relative
> to the project's storage path but that path does not make any sense in
> case of a POSTGRES storage (because POSTGRES is not a local
> filesystem-based DB in the same sense as GPKG or SPATIALITE are), so
> your file-system based asset paths are not (and cannot be) converted to
> relative paths because there is no project path we can relate to.
>
> This makes portability an issue if the project has filesystem-based
> layers (rasters in your case).
>
> There is no solution I'm aware of, storing rasters into PG is also not a
> viable option at the moment because support is currently buggy (see:
> https://github.com/qgis/QGIS/issues/30392).
>
> Cheers
>
>     I have also saved the project into PostgreSQL so that it can be shared
>     easily. Other users work on Windows computers and have the same rasters
>     under pkg data path resources folder
>     (C:/PROGRAM~1/QGIS3~1.8/apps/qgis/resources/local/raster.gpkg). But
>     when
>     they open the project, Postgis layers are loaded fine, but QGIS says
>     that raster.gpkg cannot be found under the /usr/share/... path.
>
>     I would expect that layers in the pkg data path resources folder are
>     saved with the inbuilt: prefix, but in fact they are not. Moreover, it
>     seems that one cannot select "Relative" for saving layer paths, in
>     project properties, when project is saved to PostgreSQL. Looks sensible
>     (what is the relative path to a PostgreSQL table ?), but then what
>     can I
>     do to share a PostgreSQL project with local layers ?
>
>     We all use QGIS 3.8.3.
>
>     Thank you for any advice !
>
>     Cheers
>
>     Yann
>     _______________________________________________
>     Qgis-user mailing list
>     [hidden email] <mailto:[hidden email]>
>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
>
> --
> Alessandro Pasotti
> w3: www.itopen.it <http://www.itopen.it>
>
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Handle local layers in resources folder when project saved in PostgreSQL

Jorge Gustavo Rocha-3
In reply to this post by Alessandro Pasotti-2

Hi,

In my setup - using PGSERVICES - all vector, raster, styles and projects are stored on database. This is my preferred way to organize the data: on a database. QGIS Server also takes advantage of this setup and publish the projects directly from the database, using the rasters (in db or out of db rasters).

The few things I'm not sharing on the database are SVG, layout images and fonts.

There are problems with Postgresql/GDAL access to Postgresql, but if using PGSERVICES it works.

Best regards,

Jorge

On 05/12/19 11:18, Alessandro Pasotti wrote:


On Thu, Dec 5, 2019 at 11:58 AM Yann Voté <[hidden email]> wrote:
Hi all,

I can't find a solution to the following issue, or a way to work around
it: I have created a project with some PostgreSQL layers to edit and
some raster layers on local filesystem. I work on a Linux computer and
have put the local layers into the pkg data path resources folder
(/usr/share/qgis/resources/local/raster.gpkg).


Sorry but this is not a good idea, that path is usually not user-writeable and should not be used to store any user related information.

But if I understand correctly what you were trying to do I'm afraid there is not a solution: the concept of "relative path" means relative to the project's storage path but that path does not make any sense in case of a POSTGRES storage (because POSTGRES is not a local filesystem-based DB in the same sense as GPKG or SPATIALITE are), so your file-system based asset paths are not (and cannot be) converted to relative paths because there is no project path we can relate to.

This makes portability an issue if the project has filesystem-based layers (rasters in your case).

There is no solution I'm aware of, storing rasters into PG is also not a viable option at the moment because support is currently buggy (see: https://github.com/qgis/QGIS/issues/30392).

Cheers

I have also saved the project into PostgreSQL so that it can be shared
easily. Other users work on Windows computers and have the same rasters
under pkg data path resources folder
(C:/PROGRAM~1/QGIS3~1.8/apps/qgis/resources/local/raster.gpkg). But when
they open the project, Postgis layers are loaded fine, but QGIS says
that raster.gpkg cannot be found under the /usr/share/... path.

I would expect that layers in the pkg data path resources folder are
saved with the inbuilt: prefix, but in fact they are not. Moreover, it
seems that one cannot select "Relative" for saving layer paths, in
project properties, when project is saved to PostgreSQL. Looks sensible
(what is the relative path to a PostgreSQL table ?), but then what can I
do to share a PostgreSQL project with local layers ?

We all use QGIS 3.8.3.

Thank you for any advice !

Cheers

Yann
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


--
Alessandro Pasotti
w3:   www.itopen.it

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
--
Email Signature
Logo
Geomaster
Jorge Gustavo Rocha | Software Engineer
e: [hidden email] | m: +351 910 333 888
g: 41.54094,-8.40490 | v: 510 906 109
a: Rua António Cândido Pinto, 67, 4715-400 Braga

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Handle local layers in resources folder when project saved in PostgreSQL

Yann Voté
Thank you all for your answers.

Alessandro: the resources folder contains only read-only data (reference
rasters or vectors from French national geographic institute, not to be
modified). I deploy these layers on every workstation. Is it still a bad
practice for read-only reference data to use this folder ?

Raymond: indeed I'm currently working on a plugin, and I've seen
QgsPathResolver. But documentation for this class is quite terse. but
I'll continue to investigate and experiment.

Jorge: interesting setup. Does the offline editing plugin work when
everything is in database ? In other words, are raster layers converted
offline ?

Cheers.

Yann

Le 05/12/2019 à 13:16, Jorge Gustavo Rocha a écrit :

> Hi,
>
> In my setup - using PGSERVICES - all vector, raster, styles and projects
> are stored on database. This is my preferred way to organize the data:
> on a database. QGIS Server also takes advantage of this setup and
> publish the projects directly from the database, using the rasters (in
> db or out of db rasters).
>
> The few things I'm not sharing on the database are SVG, layout images
> and fonts.
>
> There are problems with Postgresql/GDAL access to Postgresql, but if
> using PGSERVICES it works.
>
> Best regards,
>
> Jorge
>
> On 05/12/19 11:18, Alessandro Pasotti wrote:
>>
>>
>> On Thu, Dec 5, 2019 at 11:58 AM Yann Voté <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     Hi all,
>>
>>     I can't find a solution to the following issue, or a way to work
>>     around
>>     it: I have created a project with some PostgreSQL layers to edit and
>>     some raster layers on local filesystem. I work on a Linux computer
>>     and
>>     have put the local layers into the pkg data path resources folder
>>     (/usr/share/qgis/resources/local/raster.gpkg).
>>
>>
>> Sorry but this is not a good idea, that path is usually not
>> user-writeable and should not be used to store any user related
>> information.
>>
>> But if I understand correctly what you were trying to do I'm afraid
>> there is not a solution: the concept of "relative path" means relative
>> to the project's storage path but that path does not make any sense in
>> case of a POSTGRES storage (because POSTGRES is not a local
>> filesystem-based DB in the same sense as GPKG or SPATIALITE are), so
>> your file-system based asset paths are not (and cannot be) converted
>> to relative paths because there is no project path we can relate to.
>>
>> This makes portability an issue if the project has filesystem-based
>> layers (rasters in your case).
>>
>> There is no solution I'm aware of, storing rasters into PG is also not
>> a viable option at the moment because support is currently buggy (see:
>> https://github.com/qgis/QGIS/issues/30392).
>>
>> Cheers
>>
>>     I have also saved the project into PostgreSQL so that it can be
>>     shared
>>     easily. Other users work on Windows computers and have the same
>>     rasters
>>     under pkg data path resources folder
>>     (C:/PROGRAM~1/QGIS3~1.8/apps/qgis/resources/local/raster.gpkg).
>>     But when
>>     they open the project, Postgis layers are loaded fine, but QGIS says
>>     that raster.gpkg cannot be found under the /usr/share/... path.
>>
>>     I would expect that layers in the pkg data path resources folder are
>>     saved with the inbuilt: prefix, but in fact they are not.
>>     Moreover, it
>>     seems that one cannot select "Relative" for saving layer paths, in
>>     project properties, when project is saved to PostgreSQL. Looks
>>     sensible
>>     (what is the relative path to a PostgreSQL table ?), but then what
>>     can I
>>     do to share a PostgreSQL project with local layers ?
>>
>>     We all use QGIS 3.8.3.
>>
>>     Thank you for any advice !
>>
>>     Cheers
>>
>>     Yann
>>     _______________________________________________
>>     Qgis-user mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>>
>>
>> --
>> Alessandro Pasotti
>> w3: www.itopen.it <http://www.itopen.it>
>>
>> _______________________________________________
>> Qgis-user mailing list
>> [hidden email]
>> List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
> --
> Email Signature
> Logo <https://www.geomaster.pt>
> *Geomaster*
> *Jorge Gustavo Rocha* | Software Engineer
> *e:*[hidden email] | *m:*+351 910 333 888
> *g:*41.54094,-8.40490 | *v: *510 906 109
> *a: * Rua António Cândido Pinto, 67, 4715-400 Braga
>
>
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Handle local layers in resources folder when project saved in PostgreSQL

Régis Haubourg
Hi Yann,
Sharing reference datasets as files in /usr does not sound like a good idea when you already have a database. I strongly recommend using the database for this, except for rasters.   And yes, offline editing works with database, except fpr rasters :)
Regards
Régis


Le jeu. 5 déc. 2019 à 13:43, Yann Voté <[hidden email]> a écrit :
Thank you all for your answers.

Alessandro: the resources folder contains only read-only data (reference
rasters or vectors from French national geographic institute, not to be
modified). I deploy these layers on every workstation. Is it still a bad
practice for read-only reference data to use this folder ?

Raymond: indeed I'm currently working on a plugin, and I've seen
QgsPathResolver. But documentation for this class is quite terse. but
I'll continue to investigate and experiment.

Jorge: interesting setup. Does the offline editing plugin work when
everything is in database ? In other words, are raster layers converted
offline ?

Cheers.

Yann

Le 05/12/2019 à 13:16, Jorge Gustavo Rocha a écrit :
> Hi,
>
> In my setup - using PGSERVICES - all vector, raster, styles and projects
> are stored on database. This is my preferred way to organize the data:
> on a database. QGIS Server also takes advantage of this setup and
> publish the projects directly from the database, using the rasters (in
> db or out of db rasters).
>
> The few things I'm not sharing on the database are SVG, layout images
> and fonts.
>
> There are problems with Postgresql/GDAL access to Postgresql, but if
> using PGSERVICES it works.
>
> Best regards,
>
> Jorge
>
> On 05/12/19 11:18, Alessandro Pasotti wrote:
>>
>>
>> On Thu, Dec 5, 2019 at 11:58 AM Yann Voté <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     Hi all,
>>
>>     I can't find a solution to the following issue, or a way to work
>>     around
>>     it: I have created a project with some PostgreSQL layers to edit and
>>     some raster layers on local filesystem. I work on a Linux computer
>>     and
>>     have put the local layers into the pkg data path resources folder
>>     (/usr/share/qgis/resources/local/raster.gpkg).
>>
>>
>> Sorry but this is not a good idea, that path is usually not
>> user-writeable and should not be used to store any user related
>> information.
>>
>> But if I understand correctly what you were trying to do I'm afraid
>> there is not a solution: the concept of "relative path" means relative
>> to the project's storage path but that path does not make any sense in
>> case of a POSTGRES storage (because POSTGRES is not a local
>> filesystem-based DB in the same sense as GPKG or SPATIALITE are), so
>> your file-system based asset paths are not (and cannot be) converted
>> to relative paths because there is no project path we can relate to.
>>
>> This makes portability an issue if the project has filesystem-based
>> layers (rasters in your case).
>>
>> There is no solution I'm aware of, storing rasters into PG is also not
>> a viable option at the moment because support is currently buggy (see:
>> https://github.com/qgis/QGIS/issues/30392).
>>
>> Cheers
>>
>>     I have also saved the project into PostgreSQL so that it can be
>>     shared
>>     easily. Other users work on Windows computers and have the same
>>     rasters
>>     under pkg data path resources folder
>>     (C:/PROGRAM~1/QGIS3~1.8/apps/qgis/resources/local/raster.gpkg).
>>     But when
>>     they open the project, Postgis layers are loaded fine, but QGIS says
>>     that raster.gpkg cannot be found under the /usr/share/... path.
>>
>>     I would expect that layers in the pkg data path resources folder are
>>     saved with the inbuilt: prefix, but in fact they are not.
>>     Moreover, it
>>     seems that one cannot select "Relative" for saving layer paths, in
>>     project properties, when project is saved to PostgreSQL. Looks
>>     sensible
>>     (what is the relative path to a PostgreSQL table ?), but then what
>>     can I
>>     do to share a PostgreSQL project with local layers ?
>>
>>     We all use QGIS 3.8.3.
>>
>>     Thank you for any advice !
>>
>>     Cheers
>>
>>     Yann
>>     _______________________________________________
>>     Qgis-user mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>>
>>
>> --
>> Alessandro Pasotti
>> w3: www.itopen.it <http://www.itopen.it>
>>
>> _______________________________________________
>> Qgis-user mailing list
>> [hidden email]
>> List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
> --
> Email Signature
> Logo <https://www.geomaster.pt>       
> *Geomaster*
> *Jorge Gustavo Rocha* | Software Engineer
> *e:*[hidden email] | *m:*+351 910 333 888
> *g:*41.54094,-8.40490 | *v: *510 906 109
> *a: * Rua António Cândido Pinto, 67, 4715-400 Braga
>
>
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user