POST
|
Solved. public void Test2() { IFeatureClass fcClass01 = default(IFeatureClass); fcClass01 = GetFeatureClass(); // Create FeatureClassDescriptor using a value field. IFeatureClassDescriptor fcDescr = default(IFeatureClassDescriptor); fcDescr = new FeatureClassDescriptor() as IFeatureClassDescriptor; fcDescr.Create(fcClass01, null, "gdsAreaDis"); // Create Input geodataset from IGeoDataset gd = fcDescr as IGeoDataset; IInterpolationOp2 interpOp = default(IInterpolationOp2); interpOp = new RasterInterpolationOp() as IInterpolationOp2; // Create an Op (RasterMaker operator). RasterMakerOp rasterMakerOp = interpOp as RasterMakerOp;//new RasterMakerOp();// IRasterMakerOp(); // Query Op for IRasterAnalysisEnvironment. IRasterAnalysisEnvironment rasterAnalysisEnvironment = (IRasterAnalysisEnvironment)rasterMakerOp; // Set output workspace for the Op. IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory(); IWorkspace workspace = workspaceFactory.OpenFromFile("c:\\temp", 0); rasterAnalysisEnvironment.OutWorkspace = workspace; // Set cell size for the Op. object object_cellSize = (System.Object)50000; rasterAnalysisEnvironment.SetCellSize (esriRasterEnvSettingEnum.esriRasterEnvValue, ref object_cellSize); // create surface IRaster outraster = (IRaster)(interpOp.NaturalNeighbor(gd)); RasterLayer rasterlayer = new RasterLayer(); rasterlayer.CreateFromRaster(outraster); ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = ArcMap.Application.Document as ESRI.ArcGIS.ArcMapUI.IMxDocument; // Dynamic Cast ESRI.ArcGIS.Carto.IActiveView activeView = mxDocument.ActiveView; IMap map = (IMap)activeView; map.AddLayer(rasterlayer); }
... View more
08-14-2015
01:30 AM
|
0
|
0
|
238
|
POST
|
Hello! I'm trying interpolate surface using point shapefile, but ArcMap crashed on interpolation. I checked and able to do it using predefined Arctoolbox scripts, so data is ok. I use ArcGIS 10.1 SP1, Spatial Extension, MS Visual Studio 2012, .Net Framework 4. Does anyone can help in it? public void InterpolateTest() { IFeatureClass fcClass01 = default(IFeatureClass); fcClass01 = GetFeatureClass(); // see below // Create FeatureClassDescriptor using a value field. IFeatureClassDescriptor fcDescr = default(IFeatureClassDescriptor); fcDescr = new FeatureClassDescriptor() as IFeatureClassDescriptor; fcDescr.Create(fcClass01, null, "gdsA"); // Create Input geodataset IGeoDataset gd = fcClass01 as IGeoDataset; // Create Output geodataset IRaster rasOut = default(IRaster); IInterpolationOp2 interpOp = default(IInterpolationOp2); interpOp = new RasterInterpolationOp() as IInterpolationOp2; //try to interpolate - crash on this line rasOut = (IRaster)interpOp.NaturalNeighbor(gd); } public ESRI.ArcGIS.Geodatabase.IFeatureClass GetFeatureClass() { ESRI.ArcGIS.Geodatabase.IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory(); String string_RasterWorkspace = "C:\\temp\\"; String string_ShapefileName = "dis.shp"; ESRI.ArcGIS.Geodatabase.IWorkspace workspace = workspaceFactory.OpenFromFile(string_RasterWorkspace, 0); ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace; // Explict Cast ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(string_ShapefileName); FeatureClass fc = featureClass as FeatureClass; return featureClass; }
... View more
08-13-2015
05:21 AM
|
0
|
1
|
3025
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|