-1

When I run the following script (using Arc 10.2.2):

import arcpy

if __name__ == "__main__":

    # Get Parameters
    Source_CSV = arcpy.GetParameterAsText(0)
    Target_FC = arcpy.GetParameterAsText(1)

    # Get Spatial Reference of Target_CSV
    SR = arcpy.Describe(Target_FC).spatialReference.Name

    # Produce New Feature Class (Overwrites Same-Named File if it exists)    
    arcpy.management.XYTableToPoint(Source_CSV, Target_FC,"Lat", "Lng", "",SR)

...I get the following error complaining that the Target Feature Class does not exist.

Traceback (most recent call last):
  File "Q:\CSVtoASMADPointFeatureClass.py", line 10, in <module>
    SR = arcpy.Describe(Target_FC).spatialReference.Name
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\__init__.py", line 1234, in Describe
    return gp.describe(value)
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe
    self._gp.Describe(*gp_fixargs(args, True)))
IOError: "Q:\Data\Infrastructure\Infrastructure.gdb\LiftStations_Active" does not exist

As you've likely figured out, "Target_FC" is indeed the feature class referred to in the error message called "LiftStations_Active".

I can assure you before I run the script the Target_FC ("LiftStations_Active") does exist. After I run the script and get the above error I come to discover it is gone.

I assumed that "XYTabletoPoint" would simply overwrite a feature class that already exists. Perhaps its methodology is a bit more stepwise? Perhaps it first deletes any feature class (with the same name) and then creates the new feature class (of course, with the same name)? Regardless, the error refers to line 11 ("SR = arcpy.Describe(Target_FC).spatialReference.Name") and then complains that "LiftStations_Active" does not exist.

What is causing the deletion of the target feature class?

6
  • 1
    Is this in ArcGIS Pro? I can't find that function in desktop. What the error message is saying is that there's likely something wrong with the spatial reference of the output, and possibly other things too, but I can't say why it's being deleted except that when you overwrite the behavior is to delete first then create a new one, so it looks like it gets through the first step but can't create a new one because the spatial reference clashes for some reason. Commented May 18, 2018 at 0:08
  • It's in ArcGIS Advanced 10.2.2. Do you think there is something wrong with the way I'm gathering the Coordinate System (the SR variable)? I just tried removing the ".Name" from the Spathal Reference method and it gave the same error.
    – Waterman
    Commented May 18, 2018 at 0:29
  • 1
    We're both assuming that the line that causes the deletion of the Target_FC is the final line. But if it's throwing an error at line 10 that means it hasn't even got to the last line (XYTabletoPoint) yet, doesn't it?
    – Waterman
    Commented May 18, 2018 at 0:34
  • You're right waterman, it's not getting to that line... perhaps the geodatabase is bad, can you try this with a newly created file geodatabase... also check if arcpy.Exists(Target_FC): # describe else: SR = arcpy.SpatialReference(Some_default_EPSG_Code).. I'm using 10.2.1 and that tool can't be found. Commented May 18, 2018 at 0:55
  • 1
    While I don't have experience with this particular tool, never have I seen an esri tool which first deletes an output if it exists before it creates a new one. A tool will throw an output already exists error, unless you have arcpy.env.overwriteOutput set to True. I suspect the feature class got deleted by some other means. Commented May 18, 2018 at 22:04

1 Answer 1

1

ArcGIS Desktop 10.6 does not have a tool named XY Table To Point so I assume that ArcGIS Desktop 10.2.2 did not have it either.

On the other hand there is an ArcGIS Pro tool named XY Table To Point which:

Creates a new point feature class based on x- and y-coordinates defined in a table. A z-coordinate can also be used if it's defined in the table.

To me this seems to be the most important of several issues that I think you should address when developing a code snippet to investigate the error that you are receiving.

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