ESRI.ArcGIS.AnalysisTools 및 ESRI.ArcGIS.Geoprocessor
4803 단어 C#arcgisEngine 2차 개발
Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
ESRI.ArcGIS.AnalysisTools.CreateThiessenPolygons CTP = new CreateThiessenPolygons(@"D:\AEtestyao\Data\school.shp",
"D:\AEtestyao\Data\CTP.shp");
CTP.fields_to_copy = "ONLY_FID";
gp.Execute(CTP, null);
처음에는 줄곧 결과를 얻지 못하다가 인터넷에 접속하여 오랫동안 조사한 후에 마침내 해결되었다.일반적으로 도구가 등록되지 않은 경우(the tool is not licensed)
해결 방안은 다음과 같이 메인 창의 초기화 함수에 코드를 추가합니다.
public Mainform()
{
#region 초기화 라이센스
IAoInitialize m_AoInitialize = new AoInitializeClass();
esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);
//기본적으로 첫 번째는 유효하고 그 다음은 무효입니다. 이 레벨이 가장 높고 절대 다수의 기능을 사용할 수 있습니다.
//licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);최저 수준
#endregion
InitializeComponent();
}
키 코드는 Initialize Component()에 올바르게 배치해야 합니다.
원인 설명: 시스템을 구축할 때 axLicense Control은 기본적으로 esriLicense ProductCodeEngine을 사용하는데 이 등급이 가장 낮아서 ESRI를 초래한다.ArcGIS.AnalysisTools의 많은 기능을 사용할 수 없기 때문에 다시 설정해야 합니다.주의:axLicense Control에서 속성 설정을 오른쪽 단추로 누르면 설정이 적용되지 않기 때문에 코드만 추가할 수 있습니다.
ArcGIS Engine에서 GP를 호출하는 두 가지 방법
//
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geoprocessor;
// button click
private void button1_Click(object sender, EventArgs e)
{
// Geoprocessor
Geoprocessor gp = new Geoprocessor();
//
ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
intersect.in_features = @"F:\foshan\Data\wuqutu_b.shp;F:\foshan\Data\world30.shp";
intersect.out_feature_class = @"E:\intersect.shp";
intersect.join_attributes = "ONLY_FID";
// Intersect
RunTool(gp, intersect, null);
}
private void RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC)
{
// Set the overwrite output option to true
geoprocessor.OverwriteOutput = true;
try
{
geoprocessor.Execute(process, null);
ReturnMessages(geoprocessor);
}
catch (Exception err)
{
Console.WriteLine(err.Message);
ReturnMessages(geoprocessor);
}
}
// Function for returning the tool messages.
private void ReturnMessages(Geoprocessor gp)
{
string ms = "";
if (gp.MessageCount > 0)
{
for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
{
ms += gp.GetMessage(Count);
}
}
//1- GeoProcessor
Geoprocessor gp = new Geoprocessor();
object sev = null;
//2-
gp.OverwriteOutput = true;
//3-
gp.AddToolbox(@"F:\lib_test\AirportsAndGolf.tbx");
//4-
IVariantArray parameters = new VarArrayClass();
parameters.Add(@"F:\lib_test\ .xls\Sheet1$");
parameters.Add("`YEAR` = 2009");
parameters.Add("W20111");
parameters.Add(@"F:\lib_test\temp.gdb\tempwww");
//5-
gp.Execute("ModelAnalysis", parameters, null);
ESRI 공식 도움말의 예:
using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.AnalysisTools;
public void SampleBufferTool()
{
// Initialize the geoprocessor.
Geoprocessor GP = new Geoprocessor();
ESRI.ArcGIS.AnalysisTools.Buffer bufferTool = new
ESRI.ArcGIS.AnalysisTools.Buffer();
bufferTool.in_features = @"D:\St_Johns\data.mdb\roads_Buffer";
bufferTool.out_feature_class = @"D:\St_Johns\data.mdb\roads";
bufferTool.buffer_distance_or_field = "distance";
GP.Execute(bufferTool, null);
}
using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.esriSystem;
public void SampleCalculateBestPathTool()
{
// Initialize the geoprocessor.
Geoprocessor GP = new Geoprocessor();
// Add the BestPath toolbox.
GP.AddToolbox(@"C:\SanDiego\BestPath.tbx");
// Generate the array of parameters.
IVariantArray parameters = new VarArrayClass();
parameters.Add(@"C:\SanDiego\source.shp");
parameters.Add(@"C:\SanDiego\destination.shp");
parameters.Add(@"C:\SanDiego\bestpath.shp");
// Execute the model tool by name.
GP.Execute("CalculateBestPath", parameters, null);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
WebView2를 Visual Studio 2017 Express에서 사용할 수 있을 때까지
Evergreen
.Net Framework SDK 4.8
VisualStudio2017에서 NuGet을 사용하기 때문에 패키지 관리 방법을 packages.config 대신 PackageReference를 사용해야...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
WebView2를 Visual Studio 2017 Express에서 사용할 수 있을 때까지Evergreen .Net Framework SDK 4.8 VisualStudio2017에서 NuGet을 사용하기 때문에 패키지 관리 방법을 packages.config 대신 PackageReference를 사용해야...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.