share your qgis project: the relocator plugin

Since I developed qgis2leaf together with some great supporters we always struggled with sharing a qgis project: we use different layers, different visualizations and so on. It’s not easy to make sure you’re talking about the same. So why not make it possible to export a whole qgs project with one click…

The relocator plugin

The first steps I designed was to copy raster as well as vector data to a single defined directory. This is straight forward and uses the
QgsVectorFileWriter.writeAsVectorFormat(layer,path,encoding,crs,type)
for vector files distributed over your hard drive(s) and the
shutil.copyfile(src_path, dst_path)
for raster files. The only problem was to change a xml document. Yes, a qgs file is a simple xml document and so I used this nice little how-to from the python documentation:
for rank in root.iter('rank'):
	new_rank = int(rank.text) + 1
	rank.text = str(new_rank)
	rank.set('updated', 'yes')
tree.write('output.xml')
First I copy the old qgs file to the defined directory and then I adjust all the given source paths to the layers:
changing xml documents and removing paths
You will find all your data in the chosen directory along with your qgs file. Furthermore you have the possibility to store this directory in a zip file so it is easy to send the whole set by email or store it on a ftp server. Sharing was never easier:


The plugin can be downloaded and developed via github. It is already pushed to the official plugin repo by qgis but is still flagged as experimental:
The relocator plugin in qgis plugin installer
Can someone check it on a Windows or Mac? Thank you for any comments and/or issues on github!

10
Leave a Reply

avatar
7 Comment threads
3 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
7 Comment authors
Willem KorevaardisqusunStefan SimonIan HandJoris Hintjens Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
PatrickStotz
Guest
PatrickStotz

Aweome! That was long overdue. Gave it a quick test run on OS 10.10.3 / QGIS 2.8.1 and it works like a charm. Keep up the good work! Cheers

Riccardo
Guest

thanks for testing on MAC!

Riccardo
Guest

Thanks to the great community: There are already two packages in the
original repo: Qconsolidate and Qpackage. Try them out as well!

Joris Hintjens
Guest
Joris Hintjens

thanks for the work Riccardo, but I use QConsolidate for a long time, with good results. What is the difference with your new plugin?

Riccardo
Guest

well Qconsolidate doesn’t support zipping a file. Biut you’re right qconsolidate does the same. haven’t seen this plugin prior developing (like written below!)

Riccardo
Guest

and the relocator plugin supports WMS ­čśë

Ian Hand
Guest

Hi Reccardo, just tested this on a Windows 7 Professional machine, works prefect! Thanks for creating a very useful plugin, will definitely see lots of usage for future projects!

Stefan Simon
Guest
Stefan Simon

Hi.

It is an useful plugin… but I have an issue regarding json files.
I tried with a shapefile layer and a geojson layer.
On the save folder, I can see that the json layer is a shape file but the project is not updated.
So.. if you load your saved qgis project, you get “Handle bad layer” for the geoJson layer.

I’m using the plugin in a wrong way?

Thanks,
Stefan

disqusun
Guest
disqusun

I installed this after QConsolidate crashed whilst exporting my project files. It worked perfectly, pulling data from both local machine and servers.

I would suggest you add a Success message, where clicking OK closes the plug-in. I ran it in the background, and came back to find it still showed the same thing as when I first clicked OK to run it… Had to check the files manually to be sure anything had happened.

Thanks!

Willem Korevaar
Guest
Willem Korevaar

Any change that you make a 3.4 version?