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

NumberFeatures tool does not label feature correctly when new feature class is created #341

Closed lfunkhouser closed 6 years ago

lfunkhouser commented 6 years ago

From @kgonzago on June 7, 2018 19:44

6/13: Tasks remaining

When creating a new feature layer (feature class) during the Number Feature tool process, the tool:

  1. Creates a new feature class in the project GDB
  2. Adds it as a feature layer to the TOC
  3. Applies the appropriate layer file for symbology But, the features are not labeled at all. Somehow the layer file is preventing it from labeling.

Expected Behavior

Features should be labeled in the newly created feature layer

Current Behavior

Run tool on: image Get result: image Features are not labeled.

Possible Solution

Update LYRX file to provide labels as well as symbology.

Steps to Reproduce (for bugs)

  1. Open the Clearing Operations solution
  2. Open the Number features tool
  3. Choose to number the NewLocations feature layer
  4. Specify a new output feature class
  5. Run the tool.
  6. The new layer is added to the map. It has the correct symbology, but the features are not labeled.
  7. Turn on labels - for some reason, even when you turn on labels they don't display (though sometimes they do. @kgonzago and @ACueva saw it not working, then I (BB) tried again on my own ArcGIS Pro 2.1.0 machine and I could manually apply labels and have them display).

Context

Your Environment

Copied from original issue: Esri/solutions-geoprocessing-toolbox#677

lfunkhouser commented 6 years ago

From @csmoore on June 12, 2018 18:22

I ran this on Pro 2.2.12776(Beta2) and setting the symbology/labeling on the output layer using a lyrx file seems to be now working correctly for setting the labels. So this issue is dependent on Pro 2.2 final:

image

There is just a small code change needed (here) to check whether in Pro or ArcMap because a Pro .lyrx file is needed to make the GP output labeling work (a 10.X .lyr file doesn't work for this labeling scenario)

Moving/migrating NumberFeatures tool opened with issue: https://github.com/Esri/military-tools-geoprocessing-toolbox/issues/339

FYI @topowright @BobBooth @dfoll @ACueva

lfunkhouser commented 6 years ago

From @BobBooth on June 12, 2018 18:26

@csmoore - cool! So, an if product == ArcMap use lyr, if product == Pro use lyrx check here is all it would need?

lfunkhouser commented 6 years ago

From @csmoore on June 12, 2018 18:40

@BobBooth - that is correct. There is an existing method/utility for this - though its behavior is not consistent if run from arcpy outside of the Pro/ArcMap - since it returns: 1. Pro 2. ArcMap 3. Other (standalone arcpy but could be Pro or ArcMap python) - so we may need to add a method

csmoore commented 6 years ago

Addressed/added/migrated from previous clearing ops toolbox in PR #342

This should work as well as it did in the previous clearing ops repo/toolbox - though more rigorous testing of this may reveal new issues - ex.

topowright-zz commented 6 years ago

Symbology is missing from output in ArcMap and ArcGIS Pro

csmoore commented 6 years ago

@topowright - can you provide some additional info/repro steps or step me through

The issue might be the one mentioned here: https://github.com/Esri/military-tools-geoprocessing-toolbox/issues/339#issuecomment-396974424 that the exact field names "Number" and "Purpose" must exist in the input+output feature class because the layer files are set to use those fields.

Also Pro should be version 2.2.12776(Beta2) or later.

Example: ArcMap no symbols or labels with missing fields:

image

Example: Labels with fields present:

image

csmoore commented 6 years ago

I found another way to repro @topowright 's reported issue above - if you don't supply an "Output Numbered Features" parameter - the symbology will also not be applied.

This has to do with the peculiar design of this tool that allows the input parameter to sometimes be used as the output parameter if no ouput parameter is supplied. The ouput is empty in this case so GP does not apply the symbology.

I think we have had similar problems with this tool design before https://github.com/Esri/solutions-geoprocessing-toolbox/issues/607 - https://github.com/Esri/solutions-geoprocessing-toolbox/issues/607#issuecomment-331572977

image

csmoore commented 6 years ago

Just to summarize when labeling should work

Setting Labeling / Layer Symbology on the output only works currently with the NumberFeatures tool when:

  1. An output parameter "Output Numbered Features" parameter is set
  2. The field names "Number" and "Purpose" exist in the input
  3. If in Pro, using 2.2.12776(Beta2) or later

These limitations were present in the previous ClearingOps toolset/template - but we are likely finding them as a result of just doing more testing outside of the template

topowright-zz commented 6 years ago

With the information above I am going to verify the statements of @csmoore

topowright-zz commented 6 years ago

based on all the testing I have done I do not think that labels from gp tools work in ArcGIS Pro 2.2. I have tested this in image

I would like to move this out of the sprint if someone else cannot get the labels to work correctly. @dfoll and @ACueva.

BobBooth commented 6 years ago

@topowright - I think we can include logic to test whether or not the Purpose field is present and populated and choose which LYRX file to apply. Although that won't help with the Number Features tool requiring an Advanced license.

dfoll commented 6 years ago

On Pro 2.2 final the tool is not labeling for me, either upon immediate output or by trying to turn labeling off then back on. I confirmed the "Number" field is present in the input and a "Purpose" field is present in the input. I also tried making sure the purpose field had non-null text values in it. Also I made sure to use an output named differently than the input. I confirmed that the output which is not labeling does have values in the number field and the label class expression is {Number]. In the label expression I tried to switch between all four languages in the label expression as well, also no luck. I attempted to switch and label by some other field, such as "Purpose" which I also calculated values, and still no labels at all. Even .... $feature.SHAPE_AREA ...... as the expression when using Arcade would not display anything

topowright-zz commented 6 years ago

@BobBooth will try and use the old layer file that only populates simple symbology (yellow boxes with labels). If that does not work we will move on and not tackle this issue during this release. This work needs to be done in the final build of ArcGIS Pro 2.2.

BobBooth commented 6 years ago

I think I've got it working correctly now. https://github.com/Esri/military-tools-geoprocessing-toolbox/pull/347

Had to add a feature class to the featuresetsWebMerc.gdb and point the symbology LYRX file to it in order for Pro to apply the symbology. @topowright - please test.