You will get numbers with your approach, but I doubt they’ll represent what you think they represent, after demosaicing, lens corrections etc.
For starters, the demosaicing combines several pixel values. The exact influence of neighbouring pixels depends on the local situation. That means that the measured noise in a given pixel will depend on its neighbours. Not what you want… The implied interpolations will tend to lower the noise, so increase the apparent SNR
Then, you use lens corrections. Those deform the image, which implies another interpolation, messing up the noise measurements again.
If you really want to get the camera (sensor) SNR, you’d have to use something like darktable’s RGB “demosaicing” (which doesn’t demosaic at all), or dcraw’s equivalent. You’ll still have to find a way to avoid any other operations that mess up the data (including white balance, raw black and white point, etc.).
Your current method will measure an SNR, but it will be the SNR after your processing chain with a specific lens (due to the lens corrections you apply). Nothing wrong with that if that’s what you want, but it’s not the “camera SNR”.