0

I'm using R to create some plots that refer to specific values of some point in QGIS. Each plot is saved into a directory and for each point in QGIS I added a column with the path to the file.

I know 2 different method to display these plots in QGIS:

  • using the Action tool (Open file)
  • using the Field tab of the Properties menu of the layer changing the Widget from Modify value to Photo

What if I have to do tons of plots or if I have a large point dataset? Is there a way to add automatically the path to the file in the attribute table? I tried to use the field calculator but I cannot figure out the problem.

Thanks to all

BTW: QGIS 2.1.0 master on Debian 7.3

  • What did you try with the field calculator? – Nathan W Feb 13 '14 at 13:53
  • I tried to duplicate the field of the path already written.. obviously without success. – matteo Feb 13 '14 at 14:09
1

You need to understand the syntax of the expressions used in the Field Calculator ( look at What expressions for QGIS field-calculator?)

In my case, for example, every record of the layer is linked to a html file whose name is based on a numeric field of the table and I need to build the complete path of the file (ie : mypath/folder/4720988.html')

The expression:

New field (url2) =

'mypath/folder'               -> 'string variable' (your path, for example)
     ||                       -> concatenate 
         tostring("IDENT")    -> convert each value of the "Field" to string
             ||               -> concatenate
                '.html'       -> 'string variable'

enter image description here

give this result:

enter image description here

If I want to update the contents of my field with a new path ('myotherpath/othefolder/')

Update field (url2):

replace("url2",'mypath/folder','myotherpath/othefolder')

Result

enter image description here

You can even use regular expressions

  • Awesome!!!! Thanks! I will spend more time to improve the field calculator possibilities. – matteo Feb 13 '14 at 17:44

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.