0

I need to filter my raster image by a fixed threshold. So I use ILogicalOp functions. Whenever I use them, an output file will be saved on workspace, which is unwanted due to my large database. The saving happens exactly after rasOut[i] = RMath.LessThan(inputRas[i], cons01). How can I prevent this? Or how to get saved file name and delete it? Any comments would be Appreciated?

private IGeoDataset[] CalcColdThreshold(IGeoDataset[] inputRas)
{
    IGeoDataset[] rasOut = new IGeoDataset[inputRas.Length];
    IGeoDataset emptyRas=null;
    ILogicalOp RMath;
    RMath = new RasterMathOpsClass();
    IRasterAnalysisEnvironment env;
    env = (IRasterAnalysisEnvironment)RMath;
    IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactoryClass();
    IWorkspace workspace = workspaceFactory.OpenFromFile(System.IO.Path.GetFullPath(workSpace_save.Text), 0);
    env.OutWorkspace = workspace;
    IRasterMakerOp Rmaker = new RasterMakerOpClass();
    IGeoDataset cons01;
    Threshold_value = 15000;
    cons01 = Rmaker.MakeConstant(Threshold_value, false);
    for (int i = 0; i < inputRas.Length; i++)
    {
        rasOut[i] = RMath.LessThan(inputRas[i], cons01);
    } 
    return rasOut;
}
5
  • Do you want it to save somewhere else, or not save at all?
    – Juffy
    Commented May 26, 2014 at 0:20
  • It is not my final result, I don't want to save it but it is saved automatically. It occupy much space for no reason.
    – shimaSH
    Commented May 26, 2014 at 3:40
  • The problem is it has to go somewhere - if it's as big as you say, it's probably too much data to hold in memory. If you want to make it easier to clean up, I would point your env.OutWorkspace to a temporary location for the intermediate steps of the process and then delete the workspace once you're done.
    – Juffy
    Commented May 26, 2014 at 6:31
  • I will appreciate if u write an example or line of code, How address to a temporary location?
    – shimaSH
    Commented May 26, 2014 at 12:40
  • I'm not actually a C++ programmer, just trying to provide some pointers to get you going since no one else seems to have any answers. :) I've just been reading the .Net docco, and found the IScratchWorkspaceFactory interface, which might work nicely for you - instead of creating your workspace variable using .OpenFromFile, try creating a scratch workspace instead? It seems to be exactly what you're looking for.
    – Juffy
    Commented May 27, 2014 at 1:58

1 Answer 1

0

(disclaimer: I'm not actually a C++ programmer, just trying to provide some pointers to get you going since no one else seems to have any answers.) (converted from comment)

The IScratchWorkspaceFactory interface sounds like it will do what you want - instead of creating your workspace variable using IWorkspaceFactory.OpenFromFile, try creating a scratch workspace instead? According to the documentation it will be automatically cleaned up when your application exits.

Just remember to use a different workspace for your final output. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.