How can I go about using a pgfkey to place an anchor if the key is a string?
Previous answers imply that setting anchors based on keys is possible using numerical keys (like this question on Creating Tikz anchors based on pgfkey value) or boolean ("if") keys (like this question on How to define an anchor with location depending on a parameter) but I haven't had any luck finding similar examples which use strings or in modifying these examples to work with strings.
As a simple example, in the (nonfunctional) code below I'd like to be able to use the elevation key to change the location of the north east anchor (it's my understanding that the ifthen package is considered obsolete but I've used it here because I thought it most clearly conveyed the behavior I was after):
\documentclass[border=10pt]{standalone}
\usepackage{tikz, ifthen}
\makeatletter
\pgfkeys{/tikz/elevation/.initial=low}
\pgfdeclareshape{myLine}{
\savedanchor{\anchorA}{
\pgf@x=3cm
\ifthenelse{\equal{low}{\pgfkeysvalueof{/tikz/elevation}}}
{\pgf@y=1cm}{}
\ifthenelse{\equal{medium}{\pgfkeysvalueof{/tikz/elevation}}}
{\pgf@y=3cm}{}
\ifthenelse{\equal{high}{\pgfkeysvalueof{/tikz/elevation}}}
{\pgf@y=5cm}{}
}
\anchor{center}{\pgfpointorigin}
\anchor{top right}{\anchorA}
\backgroundpath{
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\anchorA}
\pgfusepath{stroke}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw [help lines, dashed, gray] (0,0) grid (5,5);
\node [myLine, elevation=value] (L) {};
\draw [red] (L.top right) circle (0.2cm);
\end{tikzpicture}
\end{document}
The resulting (desired) behavior based on keys provided to \node [myLine, elevation=value] is shown in the images below.

valuewithlow/medium/highin the document body? – frougon Jun 02 '21 at 07:37