35

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?

  • 1
    As of 2016-02-05 the QConsolidate plugin works correctly with shapefiles, tif rasters, and (!) Arc coverages. However, file geodatabase feature classes (as points) are not copied to the output folder. – Stu Smith Feb 5 '16 at 23:58
44

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:

  • You must have saved the project you're working on before attempting to consolidate it elsewhere;
  • The output format will be the project (.QGS) file, together with a folder called 'layers' that (surprise!) contains the layers;
  • QConsolidate will convert database layers into shapefiles and rewrite the project file to refer to the new shapefile;
  • While often you may want to share the consolidated project on an external / thumb drive, save it on a local hard drive first as the many write operations made will really slow things down if you try to consolidate directly onto slow media.
  • Thank you very much. QConsolidate is exactly what I was looking for. – Hendrik Pehlke Sep 13 '12 at 8:43
  • 1
    Just looked for an answer for the same problem. I guess with the Qconsolidate and relocator plugins the topic can be seen as anwered. BUT: I really hope the development of relocator picks up because QConsolidate seems to be almost dead :( Not a single commit in 2 years on the github page. – martin Jul 10 '15 at 20:02
19

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:

  • QConsolidate 0.2.1
  • QPackage 1.3
  • relocator 0.9

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

  • FileGDB: not copied or translated (data loss). Project file still references layer
  • Spatialite: translated to SHP
  • Geopackage: copied without translation
  • GeoTiff: copied intact

QPackage

  • FileGDB: translated to SHP
  • Spatialite: translated to SHP
  • Geopackage: translated to SHP
  • GeoTiff: copied intact

relocator

  • FileGDB: translated to SHP, incorrect path in project file
  • Spatialite: translated to SHP, incorrect path in project file
  • Geopackage: translated to SHP, incorrect path in project file
  • GeoTiff: copied intact

Of the three, QPackage appeared to work the best. Database connections and web service layers were not tested.

  • Excellent answer - was thinking of updating mine similarly and found this. What experience do you have of the rewritten .QGS file itself? My last experience with QConsolidate some time ago was giving malformed directories of data and QGS file. – Simbamangu Jan 21 '18 at 12:34
  • In all honesty, I don't use the plugins, but would script modifications to a copy of the QGS file as required. This answer was based on some testing for a client which I thought would be of wider benefit. – Andy Harfoot Feb 6 '18 at 9:33
6

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.

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.