Digital Geography

9. May 2015

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
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')
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!