3

QGIS 3.22.4, on Windows 11, with shapefiles and a lot of reports. On an initial project, only looking at roads, footpathes on a defined region, we started to work with new shapefiles linked to hikes in this region.

Originally, it was a marginal project, but days after days, it became greater, and now I have to envisage to have a specific QGIS project for this, of course without loosing what has ben done.

The way I imagine is to copy the whole original project to another directory (easy to do), give it a new name (is a simple rename of the qgz file enough?), and then delete the unnecessary shapefiles from the original project (easy to do).

Will this new renamed project automatically use the copied shapefiles or are there some other modifications to do? How can I check this?

I did not succeed to find documentation for this process.

2 Answers 2

5

Avoid broken links to layer sources

If you move the project to another folder and you used relative paths for your layers, all references to the files will be broken. Opening the project, QGIS will not find the layer sources. You will get a prompt Handle Unavailable Layers where you could manually set the path. If you have many layers in the project, this is cumbersome, however.

Solution: use absolute paths instead of relative ones

If you used absolute file paths in the project and stay on the same machine, you will not have any problems. So easiest solution is to make sure you save your project with absolute paths. Then you can move the project file wherever you want (as long as you stay on the same machine).

How to change to absolute paths

To check what kind of paths your project uses and to change to absolute paths, go to Menu Project > Properties > General Tab and look for Save Paths, where you can choose between Relative or Absolute. If it is set to relative path, change to absolute path and save the project again. You can than save the project file (or a copy of it) wherever you want on your machine.

enter image description here

Project Packer plugin

Alternatively, there is a plugin available called Project Packer:

Gathers scattered data to make the project portable This plugin exports a portable project by copying the data scattered on the disk into a specified directory. On output, the directory structure below the project home is copied, but unnecessary files are not copied.

Be aware

Attention: Do not delete any files you don't use in the new project as they will be deleted for all project that use this data. Delete only the layers in the QGIS project. This will not affect any data.

Advantage of relative paths

Relative paths have the advantage that you can change the absolute path (moving everything to another folde), but as long as the folder structure remains the same (e.g. saving everything - project, data, style definitions etc. - in the same folder/subfolders), you can move it around on your machine or any other computer. So this is great if you share your project+data with other persons.

Importance of data management

This sayed, you should think about how you want to design your data management. If you have basic data you use in different projects (like administrative units, rivers, streets in your area of interest), you might want to have a central folder Geodata where different project refer to the same data and you don't have to create another copy for each project - to save storage and to use the same data in case you update or change the data.

Sharing data with other persons or moving the project file to another folder is a bit more difficult, then. If you have data that you use just for one single project, it might indeed be an option to have the data in the same folder as the project.+

3
  • Thank you for your clarification. If I understand well, and if my purpose is to have a completely independant project, with its own shapefiles stored in same directory of project file, it could be better to put a relative savepath ! I am true ?
    – ClaudeVer
    Dec 26, 2022 at 11:14
  • Yes. If you want to duplicate the project to a new folder and also duplicate the data of the layer, copy/paste everything to the new folder. If you always store everything (project + data) in the same folder, you have no problems using relative path, even when sharing with other persons on other machines.
    – Babel
    Dec 26, 2022 at 11:18
  • See updated answer: Project Packer plugin, Advantage of relative paths and Importance of data management
    – Babel
    Dec 26, 2022 at 11:30
3

I would explore if you can achieve your "split project" objective working with rather than against the QGIS data paradigm (projects stored separately from layer data).

It sounds like you currently have a single directory MainProjDir with files (simplified and illustrative):

MainProjDir\MainProj.qgz
MainProjDir\BaseRaster.tiff
MainProjDir\Roads.shp
MainProjDir\Footpaths.gpkg
MainProjDir\HikeA.kml

You're now intending to split into

MainProjDir\MainProj.qgz
MainProjDir\BaseRaster.tiff
MainProjDir\Roads.shp
MainProjDir\Footpaths.gpkg

AltProjDir\HikeProj.qgz
AltProjDir\BaseRaster.tiff
AltProjDir\Roads.shp
AltProjDir\Footpaths.gpkg
AltProjDir\HikeA.kml

That is, 2 projects in separate directories, each with its own copy of the layer data. This is doable, but e.g. later changes to roads or footpaths in one project will only affect that project's copy of the data and not propagate to the other.

Why not just create 2 projects in MainProjDir each using the data it needs:

MainProjDir\MainProj.qgz
MainProjDir\HikeProj.qgz
MainProjDir\BaseRaster.tiff
MainProjDir\Roads.shp
MainProjDir\Footpaths.gpkg
MainProjDir\HikeA.kml (this one used just by HikeProj)

You can now clear unnecessary layers (and other elements) from each of the 2 projects, while letting them share the same underlying layer data where they need to, and therefore avoid propagation issues.

To do this, you could just save a copy of MainProj.qgz as HikeProj.qgz and then proceed to edit each project independently. (Just, of course, make sure that you only remove unneeded layers from each project's layer tree, not delete the layer's data files from the browser!) You can also change the styling of each layer in each project independently. But if you edit a layer's data in one project, the data edits will be saved in the underlying layer data files and available in both/all projects.

As an alternative, you could start HikeProj.qgz as a new project (in the same directory, just with a different project name). Keep it open in QGIS, but then in the Browser window, Project Home tree item, find and open up the Main project and drag and drop desired layers into your new project (drag into the canvas area or the layer tree area). The chosen layers will be brought over together with their formatting from the main project. This is as opposed to adding them from scratch in the new project, when you would have to restyle them.

Finally, if you want to keep your specialized layers (e.g. hikes) for the new project in a different directory, go right ahead. Just make sure to refer to the original layer data files for any shared layers (e.g. base map, roads, ...) in their original location.

2
  • I think with all these comments, I have all I need to achieve my objective.
    – ClaudeVer
    Dec 26, 2022 at 13:39
  • I will envisage to put everything for the new project in a new directory, duplicating files and cleaning unnecessary files. For data management, I fully agree with the comments. Knowing that there will be no real shared data between the 2 projects (except the map tiles and the extend of the project) and the new project will be managed on another computer, the full different directory seems the best solution. Thank you to all helping me to find the best solution to my problem.
    – ClaudeVer
    Dec 26, 2022 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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