Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to use the xat(n) and yat(n) in the Field Calculator but can't get them to work. Does anybody have an example how to use them? I need the start and end coordinates for line segments, does anybody know how to get those?

In the below list the xat() and yat() functions are listed. http://hub.qgis.org/wiki/17/List_of_Field_Calculator_Functions

share|improve this question
1  
Did you use xat(0) and xat(-1)? –  underdark Mar 23 '12 at 15:28
    
I have the same problem like Jonas in Qgis 1.7.3. Do somebody already now how to solve it? thanks for any adivce –  Jan Apr 26 '12 at 9:12
add comment

1 Answer 1

You'll need to create a new field for each x/y point, and use the correct index number to return the position along the line. Index 0 is the starting point, and (as far as I can tell) any negative number would return the last point.

xat(0) in the 'expression' box, no '=' sign beforehand, will fill the new field with the x coordinate of the first point along the line, yat(0) likewise for the y coordinate. Use xat(-1) for the last point along the line.

Using a consistent terminology for your columns is a good idea - x_start / y_start, for example.

share|improve this answer
    
When trying the above I get the Syntax Error with: "Invalid expression syntax. The error message of the parser is: 'syntax error, unexpected '(', expecting $end'" I'm trying with a normal ESRI Shapefile type Line. –  jonas Mar 25 '12 at 11:13
    
@Jonas - you're right - it worked for me then I realised I'm using 1.9; trying it with 1.7.4 gave me the same error (on OSX 10.7)! Does anyone know if xat(n) is somehow available in 1.7.x? –  Simbamangu Mar 25 '12 at 14:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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