[QGIS-Developer] saving a layer with the world_map.shp

Tim Sutton tim at kartoza.com
Tue May 28 01:50:23 PDT 2019


Hi

I don’t have any immediate fix for your issue, but I am glad you are enjoying my Easter egg :-) I also use it ALL THE TIME and it is really great in training courses etc. to get people quickly started with panning and zooming or putting their data in context. One day maybe we can elevate it’s status to have a button on the file toolbar that adds it to the canvas without the need for bunnies and chocolate :-)

PS for those that don’t know about the Easter egg, type ‘world’ into the coordinate box in the status bar as shown below, then press ENTER.


Regards

Tim

> On 27 May 2019, at 14:58, Raymond Nijssen <r.nijssen at terglobo.nl> wrote:
> 
> I know it was introduced as an easter egg, but I'm very happy with the built in world map in qgis. I'm using it in a plugin to automatically add a layer for the overview map in my layout. This layer points to a shapefile in my qgis install directory:
> 
> /home/raymond/programs/qgis-master/share/qgis/resources/data/world_map.shp
> 
> Now, when saving my project and somebody else opening it, the layer is invalid (of course). Is there a way to make the project point to the right file, using some kind of variable pointing to the qgis installation path?
> 
> like this:
> {QGIS_RESOURCE_PATH}/data/world_map.shp
> 
> or I could copy the world.shp into my plugin and do this:
> 
> {QGIS_PLUGIN_PATH}/my-plugin/data/world_map.shp
> 
> These paths should then be saved including the variable in the project file.
> 
> 
> 
> Another option would be to save the shp-file in the .qgz somehow but I'm not too sure if that is the way to go..
> 
> 
> 
> This is the way I create the path now:
> 
> worldShp = os.path.join(QgsApplication.pkgDataPath(), 'resources', 'data', 'world_map.shp')
> 
> 
> 
> To make the question more general, is it possible to add resources to a plugin in a way that projects point to these resources and make that work for other users too?
> 
> 
> Hope anyone can help!
> 
> Kind regards,
> Raymond
> 
> 
> _______________________________________________
> 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

—









Tim Sutton

Co-founder: Kartoza
Ex Project chair: QGIS.org

Visit http://kartoza.com <http://kartoza.com/> to find out about open source:

Desktop GIS programming services
Geospatial web development
GIS Training
Consulting Services

Skype: timlinux 
IRC: timlinux on #qgis at freenode.net

I'd love to connect. Here's my calendar link <https://calendly.com/timlinux> to make finding time easy.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190528/f2c5a9b1/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: world.jpg
Type: image/jpeg
Size: 21554 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190528/f2c5a9b1/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KartozaNewLogoThumbnail.jpg
Type: image/jpeg
Size: 6122 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190528/f2c5a9b1/attachment-0003.jpg>


More information about the QGIS-Developer mailing list