In my project, I use a lot of geodata from different directories. Now I want to give the QGIS project to a colleague (eg on a CD).
Is it possible to copy the shapes from different directories automatically to one directory?
In my project, I use a lot of geodata from different directories. Now I want to give the QGIS project to a colleague (eg on a CD).
Is it possible to copy the shapes from different directories automatically to one directory?
You're looking for the QConsolidate plugin, which works very well. It will transfer everything to a single directory and rewrite the .QGS project file (an XML file) to point to the new source locations.
QConsolidate is still listed as experimental - you'll have to enable "Show also experimental plugins" in the settings dialog.
However - it works very well. Notes:
I have just tested the three plugins that attempt to do what you ask on a project file with a range of file based formats. Here are the results:
Plugins tested were:
Tests were run on QGIS 2.18.14 64bit on Windows 10
All three plugins handled shapefiles without problem, moved data into the target directory and created a project that referenced the local copies of the datasets.
QConsolidate
QPackage
relocator
Of the three, QPackage appeared to work the best. Database connections and web service layers were not tested.
QGIS now (3.14+, possibly from 3.10?) has another option for packaging vector layers - the "Package layers" algorithm in Processing. This doesn't save the whole project as a package, but you can save all the styles together with the layers, which takes you much of the way there.
Clicking the 'input layers' options will bring up a list of all the layers in the canvas.
... then choose a location for the outputs.
I don't know about a way in QGIS itself, but the project file (.qgs) is just a text file. Therefore a primitive but effective way would be to copy everything manually into one directory, then alter the <datasource></datasource>
tags in the .qgs file either using find and replace or a regular expression to point to the new directory.
If you've got a lot of different files/directories, one option would be to automate it in python by searching for each tag in the .qgs file, copying each related file with that name to a directory, and then replacing the .qgs tag with the new directory.
There is now also the new relocator plugin. (marked as experimental as well at this moment). Gives you the opportunity to save all layers with the project file into one directory or even in a zip-file.
QGis3 Plugin: Project Packager
This QGIS plugin exports a portable project by copying data scattered on storage into a specified folder. When exporting, you can choose to copy the original files or store the data in a single GeoPackage. Note that if there is data that cannot be stored in GeoPackage, storage in GeoPackage will be disabled.
The plugin works well for me.
Coordinate Reference System (CRS) and Mesh Datasets including Datasets and Layer Properties are lost. However, this can be corrected manually.