Feature request #1211

Relative paths within QGIS project file

Added by springmeyer - about 16 years ago. Updated about 15 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Project Loading/Saving
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:11271

Description

It would be extremely useful to allow for the use of relative paths to files loaded within a Qgis project file that rest on the filesystem. This would be a user controlled setting so that when checked project files by default store the relative paths to loaded files.

History

#1 Updated by Jürgen Fischer over 15 years ago

see also #1665

#2 Updated by springmeyer - over 15 years ago

Any core devs able to give a broad overview of where and how this patch might be implemented?

I've yet to dive into qgis c++ code, but I may have an occasion to soon, and any head starts would be very welcome.

Also, if/once relative paths are supported QGIS may have the same issue as Mapnik - e.g. what are they relative too? Ideally the paths will be interpreted relative to the XML project file (rather than the location of the QGIS process), and in Mapnik this took some extra effort: http://trac.mapnik.org/ticket/326

See also http://trac.mapnik.org/ticket/324

#3 Updated by Martin Dobias over 15 years ago

Some insights:
  • raster layers are instantiated with a GDAL specific string, I believe currently only file-based datasets are supported in qgis
  • vector layers are instantiated with their URI strings which are specific for every vector data provider
  • some vector providers are file based (gpx), others database based (postgres) and I think ogr provider is mixed (supporting both files / databases)

So, being able to detect which URI is a file would enable you cut the paths to relative when saving projects. Being relative to project's path is surely the most intuitive way.

Maybe there are some more places in project file that use absolute paths... but these are the critical ones.

I would suggest to keep absolute paths default and just allow relative paths as an option. I don't know where - maybe to project settings dialog.

Hope that helps
Martin

#4 Updated by Jürgen Fischer over 15 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

Should be fixed in for single layer file data datasources

QGIS now tries to interpret the data source name of each maplayer as filename and if that doesn't exists tries to prepend the project files path, if that succeeds, that filename is taken, otherwise the data source uri is left untouched.

Obviously that'll only work if the uri actually just contains the filename. This is true for instance for single layer OGR data sources like shapefiles.

SVG symbol are now also looked up in the project path if everything else fails.

Feel free to reopen, if you think this isn't sufficient or inadvisable.

#5 Updated by springmeyer - over 15 years ago

for reference: http://www.mail-archive.com/[email protected]/msg02353.html

I'm not quite following what the above commit does. I'll need to look more closely.

In general though, don't we need a user option like Martin wrote about in the above thread? Projects should either be in absolute path storage mode (if users want the ability to move project files around freely) or in relative path mode (if users want to move project files along with their file datasources in the same folder bundle).

#6 Updated by Jürgen Fischer over 15 years ago

Replying to [comment:5 springmeyer]:

Projects should either be in absolute path storage mode (if users want the ability to move project files around freely) or in relative path mode (if users want to move project files along with their file datasources in the same folder bundle).

added in f2df6475 (SVN r10875)

#7 Updated by coatman - about 15 years ago

The ability to store relative paths for raster files should be incorporated in QGIS version 1.2.0 Daphnis project files. I am using the 1 Sep 2009 version of QGIS 1.2.0, but do not see the ability to specify storing a relative, as opposed to an absolute, path for a raster file. Please advise how to specify storing a relative path.

#8 Updated by Giovanni Manghi about 15 years ago

Replying to [comment:7 Coatman]:

The ability to store relative paths for raster files should be incorporated in QGIS version 1.2.0 Daphnis project files. I am using the 1 Sep 2009 version of QGIS 1.2.0, but do not see the ability to specify storing a relative, as opposed to an absolute, path for a raster file. Please advise how to specify storing a relative path.

see #1905

Also available in: Atom PDF