Esri / military-tools-geoprocessing-toolbox

military-tools-geoprocessing-toolbox is a collection of models, scripts, and tools for use in ArcGIS for Desktop and ArcGIS Pro. This toolbox is one component that is a part of Military Tools.
Apache License 2.0
33 stars 14 forks source link

TableToPolygon - Setting "Line" Parameter Causes Tool to Fail (Pro) #237

Closed csmoore closed 6 years ago

csmoore commented 7 years ago

Tasks to be done 16 May 2018


Expected Behavior

Setting the "Line" parameter to a field should create individual lines/polygons/etc. for each unique field We should Support strings and ints as inputs.

Current Beh

Expected Behavior

Setting the "Line" parameter to a field should create individual lines/polygons/etc. for each unique field We should Support strings and ints as inputs.

Current Behavior

Setting the "Line" parameter causes a python crash in the tool (output below)

Steps to Reproduce (for bugs)

  1. Using test data from: https://github.com/Esri/military-tools-geoprocessing-toolbox/tree/dev/testdata
  2. Run TableToPolygon tool, set the Line parameter to field "Name" from the sample csv
  3. Tool fails

Your Environment

Running script TableToPolygon...
Adding ID field: Name ...
Converting Polylines to Polygons...
PYTHON ERRORS:
Traceback info:
  File "C:\MyFiles\Work\Github\military-tools-geoprocessing-toolbox\toolboxes\scripts\ConversionUtilities.py", line 135, in polylineToPolygon
    outRows.insertRow([outPoly, inID])

Error Info:
The value type is incompatible with the field type. [Name]
ArcPy ERRORS:
Start Time: Thursday, June 29, 2017 12:28:29 PM
Adding Name to C:\Users\Chris\Documents\ArcGIS\Projects\VizTest\scratch.gdb\outputPolygons...
Succeeded at Thursday, June 29, 2017 12:28:29 PM (Elapsed Time: 0.12 seconds)
Completed script TableToPolygon...
Failed to execute (TableToPolygon).

image

BobBooth commented 6 years ago

Here's my doc from encountering this issue: The Table to Polygon tool is failing when it is run on the repo test data (TableToPolygon_single.csv) if the optional "Line Field" input is set to the Name attribute.
image

The error message is: "... PYTHON ERRORS: Traceback info: File "C:\Users\username\Documents\GitHub\military-tools-geoprocessing-toolbox\toolboxes\scripts\ConversionUtilities.py", line 135, in polylineToPolygon outRows.insertRow([outPoly, inID])

Error Info: The value type is incompatible with the field type. [Name] ..." Note, this is not a new problem with the tool in the new Python toolbox, Military Tools.pyt - I am also seeing it with the tool in "Military_Tools_arcmap.tbx"

The table contains this attribute which serves as a group identifier for sets of points that belong together in a given polygon. The result of running the tool on this data should be an output polygon for each of the named areas. Name field: image

The Table to Polyline tool is working correctly with these inputs, creating a set of line features from the related points, see: image

The tool runs correctly if it is fed a table with integer group IDs, see: image

Tool should create polygons grouped by name field, like the Table to Polyline tool does for lines, given a name field with string values, as well as an ID field with Integer values.

Steps to Reproduce (for bugs)

Using CSV test data, TableToPolyline_single.cs (https://github.com/Esri/military-tools-geoprocessing-toolbox/blob/dev/testdata/CSV/TableToPolyline_single.csv)

  1. Run the Table to Polygon tool.
  2. Accept default coordinate format
  3. X field should be MGRS_X
  4. Y field should be MGRS_Y
  5. Name the output polygons
  6. Line field should be Name
  7. Sort field should be Vsort
  8. Accept default Spatial Reference Tool will fail.

Fails in both "Military_Tools_arcmap.tbx" and "Military Tools.pyt" (Dev branjch 5/9/18) using ArcMap 10.5

BobBooth commented 6 years ago

The TableToPolygonTestCase.py has been updated to include a test that actually compares the number of features you would expect when a grouping value is used. Note 1: It fails, because the tool is currently broken. Note 2: Once the tool is fixed, the rest of the test cases should be updated to use the same logic (maybe one could be left with the old "expectedFeatures = int(1)" comparison, which tests if you're converting all of the points in a given table into a single polygon. This seems like an edge case, rather than the main use for the tool. The same applies to the TableToPolylineTestCase.py @csmoore https://github.com/Esri/military-tools-geoprocessing-toolbox/pull/290

csmoore commented 6 years ago

Looking at this now and see where the assumption is made that the field will be of type "Long": https://github.com/Esri/military-tools-geoprocessing-toolbox/blob/dev/toolboxes/scripts/ConversionUtilities.py#L98

And can't convert here: https://github.com/Esri/military-tools-geoprocessing-toolbox/blob/dev/toolboxes/scripts/ConversionUtilities.py#L123

Hopefully a straight forward fix to made the added field of type text

csmoore commented 6 years ago

Fix added to PR #290 - ready for QA/QC when merged - removing dev label

BobBooth commented 6 years ago

Fix for this caused a problem with Table to Ellipse. Bob will work on this today.

BobBooth commented 6 years ago

I believe that PR https://github.com/Esri/military-tools-geoprocessing-toolbox/pull/319 fixes this. @topowright - please review and merge.

BobBooth commented 6 years ago

Checklist test created: https://github.com/ArcGIS/solutions-defense-test-catalog/pulls

dfoll commented 6 years ago

tested manually from dev branch in pro 2.2 -- removed G-QC Verify (Checklist)

dfoll commented 6 years ago

tested on Pro 2.0 with MT 2.0 from ...\Esri\Released\ArcGISforDefense this issue was occurring there, so I am listing this in the issues addressed