3

I am trying to set up a GIS database in QGIS (2.16.1) containing some geological information. I've created a shapefile (polylines) and added a map-tip to it which displays a cross-section related to the respective line (see image).

example

HTML in Layer Properties --> Display:

This works well as long as I use absolute paths in the attribute table of the shapefile, linking to the location of the cross-section.

BUT I would like to use relative paths because there is a chance that the folder containing the QGIS file, the shapefiles and the cross-sections will be copied to a different location.

I have tried but did not succeed and google and the search here did not help me. Can someone help me with that?

One more thing: Is there a possibility to re-size the map tip according to the size of the images? I know there is a way to set a fixed size but the cross-sections I am displaying have different sizes each time.

I am relatively new to QGIS and Python.

4

In QGIS 2.16.1 you can use the variable @project_folder. This returns the path of the folder the project is saved in. When the data or datafolder is saved in this project folder as well you can concatenate a relative path.

enter image description here


You should ask one question a time, see the tour, as this helps other users find the question and answer.

But for the defined width you can add width = "100" in the image tag:

<img src= "[%"path"%]" width = "100">

See w3schools for other HTML tags as well.

  • This was exactly what I was looking for! Both tips worked out. Thank you very much for the helpful and quick reply. – Cait Aug 24 '16 at 13:17
  • Happy I could help :) – nielsgerrits Aug 24 '16 at 15:16

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.