POST
|
Hi Abel, thanks for this useful question. One way, as @Than Aung stated, is to call a Python script tool (or a ModelBuilder model tool) and call the tool by clicking on a button - the tool dialog will be shown in Geoprocessing pane. You can combine multiple tools while exposing only a few of the parameters (using organizational defaults for the other parameters) - the user will enter data and execute the tool. You can capture the result and use that in your next task in sequence. Using a custom ModelBuilder or Python script tool will hugely minimize the amount of code they would need to manage. The way you are looking for is to create a dockpane app, where you'll create a WPF dialog and provide parameters etc. Let me create a simple sample - I 'll share it once ready. Thanks, Nobbir Ahmed Esri GP team.
... View more
04-07-2020
08:54 AM
|
0
|
1
|
1929
|
POST
|
I'm afraid a single tool can solve your question unless someone comes up with a nice solution The simplest two-step process will be (conceptually): 1. to find closer crime points (pre-defined higher estimated number) within a distance from police stations. 2. iterate over step 1 for each police station. For each police station, there will be many points that are within the distance specified but those points are closer to some other police station. We need to compare distances from police stations to filter out ones that are closer to one station than all other stations. The (proposed) practical solution is: Run Generate Near Table with police stations as Input Features and crime points as Near Features. Make sure you uncheck 'Find only closest feature'. I'm afraid you won't know beforehand which values to put for Search Radius and Max number of closest features. You may need some trial and errors. Now the output of this run will be a table that will show distances of crime spots from police stations with a RANK number - closest crime point will get 1, next one will get 2 and so on. With my dummy data the output of Generate Near Table looks like this: See, the crime spots are ranked (from each police station) by distance. Next, you'll need to look at the NEAR_FID field - if a value appears more than once (eg 20 here) then the same point is being counted twice. You may need to write a Python script to weed out the duplicates. The story is not over: once you know the crime points closest to each station you'll need to run Spatial Join to transfer the attributes Let's wait - someone else might come up with a simpler and delicate solution
... View more
12-18-2019
03:56 PM
|
1
|
0
|
2599
|
POST
|
Hi Gintautas, thanks for your suggestions. We're also requesting suggestions from all users. We'll add more examples, snippets as soon as possible. Meanwhile, if you have any other comments please share. Thanks again.
... View more
12-11-2019
08:53 AM
|
0
|
1
|
2116
|
POST
|
I think Doug's suggestion is the only option. Here is a code sample that you may use: arcpy.env.overwriteOutput = True wks = os.path.join(os.getcwd(), "UpdateOneFC.gdb") # or hard code the workspace point_fc = os.path.join(wks, "cities") poly_fc = os.path.join(wks, "districts") out_fc = r"memory\\spj_out" # in_memory if on 10x # create a FieldMappings object field_mapping = arcpy.FieldMappings() # create a fieldmap object using Join Feature's District field. fm = arcpy.FieldMap() fm.addInputField(poly_fc, "District") # update the variable field properties out_fld = fm.outputField # get District field from the output field out_fld_name = "District_trns" # new name of the polygon field fm.outputField = out_fld # add back the updated field map field_mapping.addFieldMap(fm) # transfer Polygon NAMEs to point fc result = arcpy.analysis.SpatialJoin(point_fc, poly_fc, out_fc, "JOIN_ONE_TO_ONE", "KEEP_ALL", field_mapping, "WITHIN") out_fc = result.getOutput(0) # check result for testing purpose for fld in arcpy.ListFields(out_fc, "*"): print(fld.name) This will create a new feature class - I don't see any other tool can do so in-place. If you want the new field to your Target Feature Class then you use Join Field to to transfer the field back.
... View more
12-04-2019
06:26 PM
|
0
|
0
|
929
|
POST
|
Follow the code snippets in the Concepts page: ProConcepts Geoprocessing · Esri/arcgis-pro-sdk Wiki · GitHub The code snippet for opening a tool dialog is (available in the above link): string input_points = @"C:\data\ca_ozone.gdb\ozone_points";
string output_polys = @"C:\data\ca_ozone.gdb\ozone_buff";
string buffer_dist = "";
var param_values = Geoprocessing.MakeValueArray(input_points, output_polys, buffer_dist);
Geoprocessing.OpenToolDialog("analysis.Buffer", param_values); As the execution runs Asynchronously, you need to use "await" keyword: // get the model tool's parameter syntax from the model's help
string input_roads = @"C:\data\Input.gdb\PlanA_Roads";
string buff_dist_field = "Distance"; // use the distance values from a field named Distance
string input_vegetation = @"C:\data\Input.gdb\vegtype";
string output_data = @"C:\data\Output.gdb\ClippedFC2";
string tool_path = @"C:\data\CompletedModels.tbx\ExtractVegetationforProposedRoads";
var args = Geoprocessing.MakeValueArray(input_roads, buff_dist_field, input_vegetation, output_data);
var result = await Geoprocessing.ExecuteToolAsync(tool_path, args);
... View more
11-05-2019
01:11 PM
|
3
|
0
|
991
|
POST
|
The python script works out-of-process when you call the script from within .Net SDK. Unfortunately, I don't know a way to get the messages in real-time Here is an sample code that you can try with: it implements delegate and handle events (such as OnProgressMessage, OnProgressPos or OnValidate: https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing#executing-a-tool-with-the-progress-dialog Let us know if you successfully implement your objective.
... View more
10-31-2019
09:42 AM
|
0
|
1
|
1775
|
POST
|
Here is a way to get it done: import arcpy import os import sys # Make data path relative (not relevant unless data is moved here and paths modified) wks = os.getcwd() # location of the script file in_gdb = os.path.join(wks, "GeonetUserQuery.gdb") # geodatabase is in the same folder as the script's arcpy.env.overwriteOutput = True try: in_fc1 = os.path.join(in_gdb, "Eid2few") in_fc2 = os.path.join(in_gdb, "Eid4few") in_fc3 = os.path.join(in_gdb, "ElDoradoFew") out_fc = os.path.join(in_gdb, "merge_outfc2b") # construct the fieldmap fieldMappings = arcpy.FieldMappings() fieldMappings.addTable(in_fc1) # add all fields of the table fieldMappings.addTable(in_fc2) # add all fields of the table fieldMappings.addTable(in_fc3) # add all fields of the table fields = fieldMappings.fields fields_to_exclude = ['Extra1', 'Extra2', 'Extra3'] for field in fieldMappings.fields: if field.name in ['Extra1', 'Extra2', 'Extra3']: print(field.name) fieldMappings.removeFieldMap(fieldMappings.findFieldMapIndex(field.name)) #print(fieldMappings.exportToString()) arcpy.Merge_management("{};{};{}".format(in_fc1, in_fc2, in_fc3), out_fc, fieldMappings) except arcpy.ExecuteError as aex: # get arcpy-specific exception messages print(aex.args[0]) except Exception as ex: # get generic exception messages print(ex.args[0])
... View more
10-31-2019
09:27 AM
|
0
|
0
|
1659
|
POST
|
Hi @Justin Bridwell, You want to use the fieldmap in Append tool? or in Merge tool? However, field map works same in all tools. Your code example shows Append - let's go with it. As far as I understood - you want to keep only three fields - 'CO_FIPS', 'MILES', 'FLOOD_ZONE' And exclude all other fields. I assume these three fields are present in all of the input feature classes ('stream1', 'stream2', 'stream3'), right? Also, when you run your code what errors you are getting back? Here is a nice example on Esri's help page: you can play around and see whether it can be of any use to you. FieldMappings—ArcPy classes | ArcGIS Desktop
... View more
10-30-2019
05:01 PM
|
0
|
0
|
1659
|
POST
|
When you execute a gp tool you get back a result object: var result = await Geoprocessing.ExecuteToolAsync(tool_path, ....) The result object, among other information, contains the messages returned by the tool. You can get them by Messages property as follows: var messages = result.Messages In our SDK (ArcGIS Pro 2.4 API Reference Guide ), if the link does not take you directly to IGPResult, browse to: ArcGIS.Desktop.Core Assembly > Namespaces > ArcGIS.Desktop.Core.Geoprocessing > Interfaces > IGPResult > Members
... View more
10-30-2019
12:06 PM
|
0
|
3
|
1775
|
POST
|
Hi Adam, Yes, using Geodatabase API is faster - however, you'll need a deeper understanding of the geodatabase API and you'll have to handle the error checking and validation. Geoprocessing, however, has one simple approach for any tool execution. Executing via Geoprocessing API is slower than calling the fine-grain API because it calls the underlying geodatabase API. The major benefit of using GP is that you won't have to worry about validation of inputs and output - the gp framework does validation and return appropriate messages.
... View more
09-30-2019
09:24 AM
|
0
|
0
|
1199
|
POST
|
Could you please check what option is set in Pro App's Project > Options > Geoprocessing and make sure 'Add output datasets to an open map' is checked? And which version of ArcGIS Pro you are on?
... View more
08-02-2019
10:16 AM
|
0
|
0
|
1725
|
POST
|
Try this: protected override async void OnClick() { Map map = MapView.Active.Map; List<FeatureLayer> featLayers = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().ToList(); FeatureLayer inputLayer = featLayers[0]; // the first layer will be updated with symbology // Note: the layer file must have an extension of lyrx // string symbologyLayer = @"D:\ProSDKall\ApplySymbology\MyProject1\Stars.lyrx"; var parameters = Geoprocessing.MakeValueArray(inputLayer, symbologyLayer); IGPResult pGPresult = await Geoprocessing.ExecuteToolAsync("management.ApplySymbologyFromLayer", parameters); await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => map.Redraw(true) // this should redraw the layer with new symbology ); } To apply symbology from another layer in the Map, such as the second layer, get that layer as: FeatureLayer symbLayer = featLayers[1]; // symbology layer FeatureLayer inputLayer = featLayers[0]; // this layer's symbology will be updated with featLayers[1]'s symbology * Message me personally if you are still having problem
... View more
06-20-2019
02:14 PM
|
1
|
1
|
1765
|
POST
|
Try adding Geoprocessor to your solution as: using ESRI.ArcGIS.Geoprocessor; It is not giving me any error on 10.6 - that means it is still available. Now, you'll find the documentation within the above two links. Interestingly, the help topic for Geoprocessor is not visible and difficult to find The following link for Geoprocessor does not work http://resources.arcgis.com/API/ArcGIS.GeoProcessor/ESRI.ArcGIS.Geoprocessor.html
... View more
06-11-2019
02:23 PM
|
0
|
0
|
858
|
POST
|
I cannot reproduce in later version. Right now I'm on 2.4 and it runs without any errors.
... View more
06-10-2019
08:10 AM
|
0
|
1
|
865
|
POST
|
Nothing would work in SDK if that does not work in the main app (ArcGIS Pro). I just tested on our recent setup and it works (I mean I could create a Raster Dataset). @Max Max - which version of ArcGIS Pro you are on?
... View more
06-06-2019
10:19 AM
|
0
|
4
|
865
|
Title | Kudos | Posted |
---|---|---|
1 | 12-18-2019 03:56 PM | |
1 | 05-06-2020 01:18 PM | |
1 | 07-23-2021 10:33 AM | |
1 | 07-28-2020 09:10 AM | |
2 | 07-27-2020 04:47 PM |
Online Status |
Offline
|
Date Last Visited |
10-25-2021
03:13 PM
|