Select to view content in your preferred language

Create fishnet

216
3
Jump to solution
3 weeks ago
rs_gs
by
New Contributor II

Hi

I want to create a fishnet using the csharp code,Why isn't it generated after the code runs?thank you.

rs

await QueuedTask.Run(async () =>
{

string out_feature_class = @"F:\data\fishnet.shp";
double cellSizeWidth = 0; 
double cellSizeHeight = 0; 
long numRows = 10;
long numCols = 10;
string labels = "NO_LABELS";
string template = "DISPLAY";
string geometryType = "POLYGON";
var parameters = Geoprocessing.MakeValueArray(out_feature_class, null, null, cellSizeWidth, cellSizeHeight, numRows, numCols, "",labels, template, geometryType);

await Geoprocessing.ExecuteToolAsync("management.CreateFishnet", parameters);

}
});

 

0 Kudos
1 Solution

Accepted Solutions
rs_gs
by
New Contributor II

The problem is solved, two parameters are added(origin_coord,y_axis_coord), and two parameters are modified(cell_width,cell_height).And delete this code:LayerFactory.Instance.CreateLayer(new Uri(out_feature_class), mapView.Map)

 

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

Does the shapefile get created on your drive but isn't added to the map? If so, set the GPExecuteToolFlags enumeration to AddOutputsToMap in the ExecuteToolAsync.

await Geoprocessing.ExecuteToolAsync("management.CreateRandomPoints", createPointsParamsValueArray, null, CancelableProgressor.None, GPExecuteToolFlags.AddOutputsToMap);

Or does it result in nothing getting created? I return an IGPResult from my geoprocessing tasks to check if they're successful.

IGPResult createRandomPointsMessage = await Geoprocessing.ExecuteToolAsync("management.CreateRandomPoints", createPointsParamsValueArray, null, CancelableProgressor.None, GPExecuteToolFlags.AddOutputsToMap);

if (createRandomPointsMessage.IsFailed)
{
  System.Diagnostics.Debug.WriteLine("Create random points errors");
}

 

rs_gs
by
New Contributor II

I  checked the file location,no shapefile (fishnet )was created.

0 Kudos
rs_gs
by
New Contributor II

The problem is solved, two parameters are added(origin_coord,y_axis_coord), and two parameters are modified(cell_width,cell_height).And delete this code:LayerFactory.Instance.CreateLayer(new Uri(out_feature_class), mapView.Map)

 

0 Kudos