Hi. I'm having some problems using the raster interpolation operations from C#.
Now, I'm not sure if I'm using the API the way it's meant to be used, so any help pointing me in the right direction is appreciated.
Let's say I have some point data files and I want to interpolate the data and create a raster from it.
Easy, just use the
Create Raster tool.
As the result, I get the raster image I want. Everything is fine.
Now, the thing is, I want to do the same but from C# to automate some operations.
First, I have the data loaded in memory and apply some operations to it.
To invoke the
InterpolateMinimumCurvature method, I first need to write my data to a file, so I write an ascii file with the data and then call the interpolation method.
If I use the exact same data as before (without modifying it at all) I get the following result:
The result is... somewhat similar. But it has that horrible horizontal noise lines.
I have checked the parameters, they are the same (i think) and even checked the numbers written to the ascii file and I could not find any sort of rounding error or anything suspicious.
Here is the interpolation code used:
private void Interpolate(string strInputFile, string strOutputFile)
{
RasterInterpolationOptions interpolationOptions = new RasterInterpolationOptions
{
Preferences =
{
AutoCacheSize = true,
CacheSize = 0,
TemporaryDirectory = ""
}
};
string strCoordSystem = "CoordSys Earth Projection 1, 104";
RasterInterpolationInputFileDetails file = new RasterInterpolationInputFileDetails();
file.DataFieldIndexes.Add(2);
file.XFieldIndex = 0;
file.YFieldIndex = 1;
file.FileType = RasterInterpolationInputFileType.ASCII_SPACE;
file.FilePath = strInputFile;
file.HeaderRows = 0;
file.CoordSysString = strCoordSystem;
file.SubFileName = "*.*";
interpolationOptions.InputDetails.Add(file);
interpolationOptions.OutputDetails.FilePath = strOutputFile;
interpolationOptions.OutputDetails.DriverId = DriverID.MRR.GetString();
interpolationOptions.OutputDetails.AutoDataType = true;
interpolationOptions.OutputDetails.CoordSysString = strCoordSystem;
interpolationOptions.Geometry.Extent.Auto = true;
interpolationOptions.Geometry.CellSize.Auto = true;
RasterInterpolationMinimumCurvature minimumCurvatureOptions = new RasterInterpolationMinimumCurvature();
minimumCurvatureOptions.ParameterType.UnitsType = RasterInterpolationParameterUnitsType.Cell;
minimumCurvatureOptions.ParameterType.UnitCode = MapInfoUnitCode.Meters;
minimumCurvatureOptions.Iterations = RasterInterpolationIterationIntensity.Normal;
minimumCurvatureOptions.PercentChange = 0.001;
minimumCurvatureOptions.SplineTension = 0;
minimumCurvatureOptions.StampMethod = RasterInterpolationMinimumCurvatureStampingMethod.AverageLastInWeighted;
minimumCurvatureOptions.Smoothing.Type = RasterInterpolationSmoothingType.Gaussian;
minimumCurvatureOptions.Smoothing.Level = 5;
minimumCurvatureOptions.Clip.Method = RasterInterpolationClipMethod.None;
RasterApiOptions apiOptions = new RasterApiOptions();
RasterCreationOptions creationOptions = new RasterCreationOptions
{
CompressionOptions = new RasterCompressionOptions(RasterCompressionType.DataBalanced, 3),
PredictiveEncoding = EncodingType.PreviousColumnLinear
};
apiOptions.CreationOptions = creationOptions;
RasterInterpolation.InterpolateMinimumCurvature(interpolationOptions, minimumCurvatureOptions, apiOptions);
}
Here is another sample:
The left image was created from MapInfo using
CreateRaster the right one was created using the same code as before.
Any Ideas of what could be happening?
(Using MapInfo Pro 17.0 64 bits, Windows 7 SP1)
------------------------------
Lucas Pandolfo
Knowledge Community Shared Account
Shelton CT
------------------------------