In short: Right now, we have bits of code here and there doing masking: sometimes only for vectors (in CLI), sometimes for rasters too (in spatialstats module), and used to have code with exclusion/inclusion (old dem_coregistration of @adehecq).
We should consolidate everything in a single function covering all cases, and tested.
Started with discussion here: #860 (comment)
Will be especially useful for the CLI to allow users to provide various masks, but not only.