[Qgis-user] path to basic world map

Nyall Dawson nyall.dawson at gmail.com
Tue Feb 11 15:06:48 PST 2025


On Thu, 6 Feb 2025 at 22:44, Andrea Giudiceandrea via QGIS-User
<qgis-user at lists.osgeo.org> wrote:
>
> > Stefan Giese (WhereGroup) stefan.giese at wheregroup.com
> > Thu Feb 6 02:56:04 PST 2025
> > I would better use:
> >
> > |QgsApplication.prefixPath() |
>
> Actually QGIS uses QgsApplication.pkgDataPath()
>
> ***
> https://github.com/qgis/QGIS/blob/6b4ffb39a887a4f10d04373f27250b6d7b1f2293/src/app/qgsstatusbarcoordinateswidget.cpp#L281-L294
>
> fileName = QgsApplication::pkgDataPath() + QStringLiteral(
> "/resources/data/world_map.gpkg|layername=countries" )
> ***
>
> Anyway, on Windows (OSGeo4W), it looks like that
> QgsApplication.prefixPath() is the same as QgsApplication.pkgDataPath(),
> but that may be not true on all systems.

Just use

    QgsPathResolver().readPath('inbuilt:/data/world_map.gpkg')

that will always resolve to the full path, and is stable across
different environments/installations.

Nyall


>
> Regards.
>
> Andrea
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


More information about the QGIS-User mailing list