Empty 'arcpy.Project_management' result linked to size of input

07-24-2020 02:10 PM
New Contributor III

I have written Python code to perform the following (sample code attached):

1) import a tab-delimited coordinates file;

2) add this information into a '.shp' file;

3) convert the coordinate system of the '.shp' file into a projected coordinate system.

However, when running this code through ArcMap, I've been experiencing issues on step (3) where the Projected output from the "arcpy.Project_management" command sometimes returns an empty result (there is no error message; ArcMap says the conversion occurred successfully). The problem seems linked to the size of the input file. I describe this (and other oddities) below:

1) The input files are of the exact same tab-delimited structure ('X_Coord   Y_Coord   Date   Data'), the only difference between them is the amount of data within them. One ~1500 line file converted fine, but I discovered that I could make this error occur when I manually removed lines of data in Notepad: reduction to 1002-1499 lines of data would still work properly, but reducing it to <= 1001 lines lead to an empty result (it didn't seem to matter which lines I deleted). But the number of lines where this error occurs isn't set to the suspicious ~1000 line threshold: A ~450 line file would return a blank output, but doubling this input file (making it ~900 lines) did properly get processed by the Project command.

2) In the majority of cases when this error occurs, the attributes of the input '.shp' file (from step (2) above) is also emptied after the Project step is called. Note that this issue does not happen if the Project command is comment out (in other words, the data was there before Project was called). Despite being empty, if I use the "zoom to layer" command, ArcMap does zoom in to the proper region (even though it isn't displaying any information, it's still there in some capacity; this is not true for the Projected output however).

3) As I mentioned earlier, there is no error message. ArcMap acts as if the "arcpy.Project_management" step was successful.

4) These troublesome input files will converted just fine when processing these files manually through ArcMap (these steps being: 'Add Data' > 'Display XY Data' > 'Save as a Shape File' > 'Project' tool). But if I run my program (without the Project command), and then try to manually use the Project command within ArcMap itself on the input generated by my code, the error occurs, which seems to indicate this issue may be on how the input file is set up, and not the Project command itself.

Any help would be most appreciated, thank you! Apologies if this was far too much detail.

EDIT - some progression on the problem

1. The problem does not occur when Editor mode turned on within ArcMap 

2. When Editor mode turned off, I could fix the problem by exporting the input as a new shape file (the new shape file would no longer cause the issues the original shape file was experiencing)

3. When attempting to simulate this "export" fix programmatically (in ArcPy), the following functions did NOT work: 

- "FeatureClasstoShapeFile" (empty output, no error)

- "CopyFeatures" (empty output, error code '000117')

- "Project_management" without changing the coordinate data (empty output, no error)

- "RecalculateFeatureClassExtent" (input file becomes greyed out [with an !] and unusable in the Table of Contents)

Well, I found a solution for now, but I'd love any ideas on why this issue was happening in the first place.

Tags (2)
0 Kudos
0 Replies