1

This question already has an answer here:

Make Feature Layer with an SQL Selection Expression against a geometry property like length fails when the source feature class is in an in_memory workspace. An otherwise identical model works just fine when the feature class source is in a regular workspace (file-gdb).

ERROR 000358: Invalid expression Shape_Length = 0
Failed to execute (Layer of Zero Length Lines).

I'm using ArcGIS Desktop 10.3.1 but don't believe the issue to be version specific.

Fail:

Model diagram and relevant tool properties for failure situation

Success:

Model diagram and relevant tool properties for success situation

marked as duplicate by PolyGeo Sep 11 '15 at 22:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I think we should probably Merge this Q&A with the Duplicate because the underlying cause is identical and your answer will apply to both. – PolyGeo Sep 11 '15 at 22:57
  • @PolyGeo that'd be fine by me, providing the question of this one doesn't get lost (been awhile since I was involved in a merge, don't remember how it works). – matt wilkie Sep 15 '15 at 21:06
2

Answer from Esri Canada tech support:

The behaviour you are bumping is a known limitation of in memory layers. They actually don't have a shape_length field to access. For example, if you add the output of the XY to Line tool to your display and you then open the attribute table you shouldn't see a shape_length field available.

That being said, I believe there is an easy solution. In your model if you add a "Add Geometry Attributes" tool in between the XY to Line and the Layer of Zero Length Lines tool and ask that Add Geometry Attributes tool to calculate length it will add a LENGTH field that you can leverage in the Layer of Zero Length Lines tool.

In my case the simplest change is to just not use in_memory at all as the performance gain is negligible. I was using memory as a shortcut to not adding a Delete step at the end of the model. The information for what is going on though is important and will surely crop up elsewhere.

Not the answer you're looking for? Browse other questions tagged or ask your own question.