Recognise a Digit from a Positional Encoding
JavaScript (Node.js),  89 ... 77  71 bytes
Saved 6 bytes by using the modulo chain provided by @KjetilS.
s=&gt;Buffer(s).map(c=&gt;o|=p*=4**(c%5)/8,o=p=4**8)|(o/=o&amp;-o)*321%3081%53%11

Try it online!
How?
We take the ASCII code \$c\$ of the direction character modulo \$5\$ to map it to an index in \$\{0,1,2,3\}\$.
For each direction, we update a bit mask \$p\$ by shifting it by a specific amount and mark the bits that are visited in another bit mask \$o\$.
 char. | ASCII | mod 5 | shift
-------+-------+-------+-------
  'U'  |   85  |   0   | &gt;&gt; 3
  'L'  |   76  |   1   | &gt;&gt; 1
  'R'  |   82  |   2   | &lt;&lt; 1
  'D'  |   68  |   3   | &lt;&lt; 3

Conveniently, the shift is equivalent to multiply \$p\$ by:
$$\frac{4^{(c\bmod 5)}}{8}$$
We start with both \$p\$ and \$o\$ set to \$4^8=2^{16}\$. This value is safe because we will never right-shift by more than \$4\times 3 + 2\times 1=14\$ (e.g. with &quot;UUUULL&quot;, which draws a \$7\$, or any other path going from the bottom-right to the top-left corner). Likewise, we will never left-shift by more than \$14\$ and never exceed \$2^{30}\$. So, both \$p\$ and \$o\$ remain 32-bit values.
Because we don't know which cell in the digit was our starting point, we normalize the final value of \$o\$ by removing all trailing zeros:
o /= o &amp; -o

We end up with a unique 15-bit key identifying the digit.
 digit |   binary mask   | decimal
-------+-----------------+---------
   0   | 111101101101111 |  31599
   1   | 001001001001001 |   4681
   2   | 111001111100111 |  29671
   3   | 111100111100111 |  31207
   4   | 100100111101101 |  18925
   5   | 111100111001111 |  31183
   6   | 111101111001111 |  31695
   7   | 100100100100111 |  18727
   8   | 111101111101111 |  31727
   9   | 111100111101111 |  31215

It can be seen as a binary representation of the digit shape rotated by 180°. For instance:
                       100    111
                       100    001
100 100 100 100 111 -&gt; 100 -&gt; 001 -&gt; &quot;7&quot;
                       100    001
                       111    001

We apply the following function to turn it into the expected digit:
$$f(n)=\big(((n\times 321)\bmod 3081)\bmod 53\big)\bmod 11$$