#JavaScript (ES6), 77 bytes Expects a 0-based index. <!-- language-all: lang-javascript --> (h,w,i)=>[...'12221000'].map((k,j,a)=>(i+w+~-k)%w+w*(~~(i/w+h+~-a[j+2&7])%h)) [Try it online!](https://tio.run/##bY7BTsMwEETvfMVeSm08dXaduIFD@ZGqB6u0JGlpqhbhW349WC4gRJD2NDNvZ7rwEa7bS3t@X5z6l924X42qQUSrV89ra@1cnHPCzPONfQtnpQ7oEJKpWhPNsDjoWTTxQQ2DaotomiSFdWfcfb3Rs0brcdufrv1xZ4/9q9qrChW81lQUxCABOVAFWoIeQU9J4bspwDdAfPJTXkpQmeE6w36CeMgvJD2XlORc5nNZ/QcRlHBfSI7dxv1M5Elevlcx/rvxEw "JavaScript (Node.js) – Try It Online") The surrounding indices are returned in the following order: $$\begin{matrix}5&4&3\\6&\cdot&2\\7&0&1\end{matrix}$$