So I have a property field called 'offset', type=integer, range=0-359. The intent is to draw an svg symbol that it offset 5 units radially away from the feature coordinate at the angle (in degrees) specified in the 'offset' field. Basically if 'offset' is 45 and the feature coordinate is 0,0 then the symbol will be drawn at x=5*acos(45) y=5*asin(45) (sorry if the trig is wrong for the moment, you get the idea). If 'offset' is 90 and the feature is at 0,0 then the symbol will be at x=5 y=0.

SO: the question is how to write this expression in the Data Defined Properties of the marker in the style dialog box?

(After hitting Data Defined Properties in the SVG marker dialog, check the 'Offset' box and no others...)

Ignoring the formulas for a minute, to get the syntax straight, I'm trying these on an object with 'offset' value = 5.

I've tried:

"offset","offset" -> not a valid expression

'"offset","offset"' -> valid expression, but no actual offset

concat(tostring("offset"),',',tostring("offset")) -> valid expression, but no actual offset

concat(tostring(offset),',',tostring(offset)) -> valid expression, but no actual offset

Several of the attempts give 'Expression is invalid' under 'Output preview' with the following, or similar, under 'more info':

Parser Error: syntax error, unexpected COMMA, expecting $end

Eval Error: No root node! Parsing failed?

As a reality check, the following expressions DO work as expected:



But the following gives the 'Expression is invalid' error: 5,5

So, apparently it does want a string? Can anyone provide the correct syntax? Thanks!

1 Answer 1


This works for me:

format('%1,%2', tostring("offset"),5)

If offset is used in both places you can do

format('%1,%1', tostring("offset"))

This is the same as doing:

tostring("offset") || ',' || tostring("offset")

but I find it clearer to use format()

format() returns a string. Using || also returns a string.

  • Thanks! that's the ticket. Where did you find this out - just practice or experience, or, is there some secret doc that I didn't find?
    – Tom Grundy
    Commented Oct 25, 2013 at 15:21
  • The final expression I used is: format('%1,%2', tostring(5*cos("offset"/57.2957795)), tostring(5*sin("offset"/57.2957795)))
    – Tom Grundy
    Commented Oct 25, 2013 at 15:22
  • I helped write the expression stuff and added the format function :)
    – Nathan W
    Commented Oct 26, 2013 at 0:59

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.