本文整理汇总了C#中Geoprocessor类的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor类的具体用法?C# Geoprocessor怎么用?C# Geoprocessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Geoprocessor类属于命名空间,在下文中一共展示了Geoprocessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectFeaturesAndRunCopyFeatures
private static void SelectFeaturesAndRunCopyFeatures()
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1: Make feature layers using the MakeFeatureLayer tool for the inputs to the SelectByLocation tool.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize the Geoprocessor
Geoprocessor GP = new Geoprocessor();
// Initialize the MakeFeatureLayer tool
MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer();
makefeaturelayer.in_features = @"C:\data\nfld.gdb\wells";
makefeaturelayer.out_layer = "Wells_Lyr";
RunTool(GP, makefeaturelayer, null);
makefeaturelayer.in_features = @"C:\data\nfld.gdb\bedrock";
makefeaturelayer.out_layer = "bedrock_Lyr";
RunTool(GP, makefeaturelayer, null);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2: Execute SelectLayerByLocation using the feature layers to select all wells that intersect the bedrock geology.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize the SelectLayerByLocation tool
SelectLayerByLocation SelectByLocation = new SelectLayerByLocation();
SelectByLocation.in_layer = "Wells_Lyr";
SelectByLocation.select_features = "bedrock_Lyr";
SelectByLocation.overlap_type = "INTERSECT";
RunTool(GP, SelectByLocation, null);
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3: Execute SelectLayerByAttribute to select all wells that have a well yield > 150 L/min.
/////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize the SelectLayerByAttribute tool
SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute();
SelectByAttribute.in_layer_or_view = "Wells_Lyr";
SelectByAttribute.selection_type = "NEW_SELECTION";
SelectByAttribute.where_clause = "WELL_YIELD > 150";
RunTool(GP, SelectByAttribute, null);
////////////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 4: Execute CopyFeatures tool to create a new feature class of wells with well yield > 150 L/min.
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize the CopyFeatures tool
CopyFeatures CopyFeatures = new CopyFeatures();
CopyFeatures.in_features = "Wells_Lyr";
CopyFeatures.out_feature_class = @"C:\data\nfld.gdb\high_yield_wells";
RunTool(GP, CopyFeatures, null);
}
示例2: DriveTimes
public DriveTimes()
{
InitializeComponent();
graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
bufferSymbols = new List<FillSymbol>(
new FillSymbol[] { LayoutRoot.Resources["FillSymbol1"] as FillSymbol,
LayoutRoot.Resources["FillSymbol2"] as FillSymbol,
LayoutRoot.Resources["FillSymbol3"] as FillSymbol });
_geoprocessorTask = new Geoprocessor("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/GPServer/Generate%20Service%20Areas");
_geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
_geoprocessorTask.StatusUpdated += GeoprocessorTask_StatusUpdated;
_geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted;
_geoprocessorTask.Failed += GeoprocessorTask_Failed;
MyDrawObject = new Draw(MyMap)
{
IsEnabled = true,
DrawMode = DrawMode.Point
};
MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
}
示例3: Init
private void Init(AxMapControl mc, int programID)
{
gp = new Geoprocessor();
mapControl = mc;
UpdateMapLayerNameList(mapLayerNameList, mapControl);
program = new Program();
program.id = programID;
program.select();
project = new Project();
project.id = program.projectID;
project.select();
netSize = program.getRelatedNetSize();
conditionList = program.getAllRelatedCondition();
baseFeature = GisUtil.GetBaseFeature(mapControl, project.baseMapIndex);
mapFolder = System.IO.Path.GetDirectoryName(project.path);
targetFolder = generateFolder(mapFolder);
foreach (Condition condition in conditionList)
{
if (condition.type == C.CONFIG_TYPE_STANDARD)
{
totalStandardValue += condition.value;
}
}
fishnetPolygonName = "polygon.shp";
fishnetName = "fishnet.shp";
fishnetWidth = netSize.width;
fishnetHeight = netSize.height;
featureList = new List<Feature>();
}
示例4: ViewShedToolViewModel
public ViewShedToolViewModel()
{
StartViewShedCommand = new RelayCommand(OnStartViewShedCommand);
CloseViewShedCommand = new RelayCommand(OnCloseViewShedCommand);
_gpTask = new Geoprocessor(new Uri(ViewshedServiceUrl));
}
示例5: ClipRaster
public static void ClipRaster(string inRaster, string inClipFeature, string outTempRaster)
{
Clip clipTool = new Clip();
//set clip parameters
clipTool.in_raster = inRaster;
clipTool.out_raster = outTempRaster;
//clip extent
clipTool.in_template_dataset = inClipFeature;
Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
gp.AddOutputsToMap = false;
try
{
IGeoProcessorResult result = (IGeoProcessorResult)gp.ExecuteAsync(clipTool);
while(result.Status != esriJobStatus.esriJobSucceeded)
{
//Console.WriteLine(result.Status.ToString());
System.Threading.Thread.Sleep(100);
}
}
catch (Exception ex)
{
object level = 0;
Console.WriteLine(gp.GetMessages(ref level));
Console.WriteLine(" Failed to clip raster using ESRI clip tool " + ex.Message);
}
}
示例6: using
void IClip.ClipByLayerFileInsideSde(object in_feature, string in_layer_file_path, object clip_feature, string clip_layer_file_path, string out_feature)
{
using (ComReleaser releaser = new ComReleaser())
{
try
{
Geoprocessor gp = new Geoprocessor();
IDataManager _dataManager = new DataManager(this._environment);
ESRI.ArcGIS.AnalysisTools.Clip clipTool = new ESRI.ArcGIS.AnalysisTools.Clip();
//releaser.ManageLifetime(gp);
//releaser.ManageLifetime(clipTool);
//IVariantArray param = new VarArrayClass();
string inlayer = string.Format("{0}.lyr", in_layer_file_path);
string cliplayer = string.Format("{0}.lyr", clip_layer_file_path);
//MessageBox.Show(string.Format("line 61 GExtractTool in={0}, clip={1}", inlayer, cliplayer));
_dataManager.SaveToLayerFile((ILayer)in_feature, inlayer);
_dataManager.SaveToLayerFile((ILayer)clip_feature, cliplayer);
//MessageBox.Show(((IFeatureLayer)in_feature).FeatureClass.AliasName);
gp.SetEnvironmentValue("workspace", this._environment);
clipTool.in_features = inlayer;
clipTool.clip_features = cliplayer;
clipTool.out_feature_class = out_feature;//string.Format("{0}{1}", this._temFullPath, out_feature);//"C:\\tayninh\\temp\\tempmdb.mdb\\" + out_feature;
runTool(gp, clipTool, null);
}
catch (Exception err) { MessageBox.Show("loi clip: " + err.ToString()); }
}
}
示例7: MapInfoToMDB
/// <summary>
/// mapinfo格式转mdb(包括mif,tab)
/// </summary>
/// <param name="strMapInfoFilePath">mapinfo数据所在的文件夹(批量转换)或者mapinfo数据文件路径(单个转换)</param>
/// <param name="strMDBPath">输出mdb的完整路径</param>
/// <returns></returns>
private bool MapInfoToMDB(string strMapInfoFilePath,string strMDBPath)
{
try
{
if (strMapInfoFilePath == "" || strMDBPath == "")
return false;
Geoprocessor geoprocessor = new Geoprocessor();
QuickImport conversion = new QuickImport();
//有扩展名,表示为单个文件
if (System.IO.Path.HasExtension(strMapInfoFilePath))
{
conversion.Input = strMapInfoFilePath;
}
else
{
//否则为批量文件
conversion.Input = "MAPINFO," + strMapInfoFilePath + "\\*.*,\"RUNTIME_MACROS,\"\"FME_TABLE_PASSWORD,,_MERGE_SCHEMAS,YES\"\",META_MACROS,\"\"SourceFME_TABLE_PASSWORD,\"\",METAFILE,MAPINFO,COORDSYS,,IDLIST,,__FME_DATASET_IS_SOURCE__,true\"";
}
conversion.Output = strMDBPath;
return RunTool(geoprocessor, conversion, null);
}
catch (Exception ex)
{
On_ProgressFinish(this, "转换过程中出现异常,转换结束,错误原因:" + ex.Message);
}
return false;
}
示例8: FieldCal
//执行计算,输出计算结果信息字符串
private string FieldCal(IFeatureLayer pFtLayer, string strExpression)
{
txtMessage.Text = "正在计算请稍后……\r\n";
try
{
Geoprocessor Gp = new Geoprocessor();
Gp.OverwriteOutput = true;
CalculateField calField = new CalculateField();
calField.expression = strExpression;
Gp.Execute(calField, null);
for (int i = 0; i < Gp.MessageCount; i++)
{
txtMessage.Text += Gp.GetMessage(i).ToString() + "\r\n";
}
return "计算成功";
}
catch (Exception e)
{
txtMessage.Text += e.Message;
return "计算失败" + e.Message;
}
}
示例9: ClipByLayer
/// <summary>
/// 两图层进行裁剪运算
/// </summary>
/// <param name="inputLayer">被裁剪图层</param>
/// <param name="clipLayer">裁剪图层</param>
/// <param name="outputFullPath">输出图层完整路径</param>
public void ClipByLayer(ILayer inputLayer, ILayer clipLayer, string outputFullPath)
{
string inputPath = GetLayerPath(inputLayer);
string clipPath = GetLayerPath(clipLayer);
Clip clipTool = new Clip();
clipTool.in_features = inputPath;
clipTool.clip_features = clipPath;
clipTool.out_feature_class = outputFullPath;
Geoprocessor processor = new Geoprocessor();
IGPProcess process = null;
processor.OverwriteOutput = true;
process = clipTool;
processor.Validate(process, true);
processor.Execute(process, null);
FileInfo fi = new FileInfo(outputFullPath);
string pathDir = fi.Directory.FullName;
string name = fi.Name;
IWorkspaceFactory wsf = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace fws = wsf.OpenFromFile(pathDir, 0) as IFeatureWorkspace;
IFeatureClass featCls = fws.OpenFeatureClass(name);
IFeatureLayer layer = new FeatureLayerClass();
layer.FeatureClass = featCls;
layer.Name = featCls.AliasName;
m_mapControl.Map.AddLayer(layer as ILayer);
}
示例10: FeatureLayerChangeVersion
public FeatureLayerChangeVersion()
{
InitializeComponent();
featureLayer = (MyMap.Layers["ServiceConnections"] as FeatureLayer);
Geoprocessor gp_ListVersions = new Geoprocessor("http://sampleserver6.arcgisonline.com/arcgis/rest/services/GDBVersions/GPServer/ListVersions");
gp_ListVersions.Failed += (s, a) =>
{
MessageBox.Show("Geoprocessing service failed: " + a.Error);
};
gp_ListVersions.ExecuteCompleted += (c, d) =>
{
VersionsCombo.DataContext = (d.Results.OutParameters[0] as GPRecordSet).FeatureSet;
foreach (Graphic g in (d.Results.OutParameters[0] as GPRecordSet).FeatureSet.Features)
{
if ((g.Attributes["name"] as string) == featureLayer.GdbVersion)
{
VersionsCombo.SelectedValue = g;
break;
}
}
};
List<GPParameter> gpparams = new List<GPParameter>();
gpparams.Add(new GPRecordSet("Versions", new FeatureSet()));
gp_ListVersions.ExecuteAsync(gpparams);
}
示例11: Geoprocessor
void IAppend.Append(IFeatureClass fcSource, IFeatureClass fcTarget)
{
Geoprocessor gp = new Geoprocessor();
ESRI.ArcGIS.DataManagementTools.Append pAppend = new ESRI.ArcGIS.DataManagementTools.Append(fcSource, fcTarget);
gp.SetEnvironmentValue("workspace",this._environment);
pAppend.schema_type = "NO_TEST";
runTool(gp, pAppend, null);
}
示例12: ViewShed
public ViewShed()
{
InitializeComponent();
_geoprocessorTask = new Geoprocessor("http://serverapps101.esri.com/arcgis/rest/services/ProbabilisticViewshedModel/GPServer/ProbabilisticViewshedModel");
_geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
_geoprocessorTask.Failed += GeoprocessorTask_Failed;
graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
}
示例13: ConvertFeatureCls2Raster
//将FeatureClass数据转换为Raster数据
public static void ConvertFeatureCls2Raster(Geoprocessor gp, string pathIn, string pathOut)
{
ESRI.ArcGIS.ConversionTools.FeatureToRaster feature2raster = new ESRI.ArcGIS.ConversionTools.FeatureToRaster();
feature2raster.in_features = pathIn;
feature2raster.out_raster = pathOut;
feature2raster.field = "Shape";
RunTool(gp, feature2raster, null);
}
示例14: FeaturesTo3D
//features to 3D
public static bool FeaturesTo3D(Geoprocessor gp, string pathIn, string pathOut)
{
ESRI.ArcGIS.Analyst3DTools.FeatureTo3DByAttribute featureTo3D = new ESRI.ArcGIS.Analyst3DTools.FeatureTo3DByAttribute();
featureTo3D.in_features = pathIn;
featureTo3D.out_feature_class = pathOut;
featureTo3D.height_field = "Contour";
return RunTool(gp, featureTo3D, null);
//IGPProcess tools = null;
}
示例15: DriveTimes
public DriveTimes()
{
InitializeComponent();
_geoprocessorTask =
new Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons");
_geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted;
_geoprocessorTask.Failed += GeoprocessorTask_Failed;
}