AnsweredAssumed Answered

Spatial Reference Object Creation Error (arcpy)

Question asked by jsnyder21 on Sep 2, 2015
Latest reply on Sep 2, 2015 by jsnyder21



I am currently attempting to create a Python script tool that takes a user-specified GPX file (GPS data), and converts this data into ArcGIS features, which need to be in a specific coordinate system. I understand that there is a 'GPX to Features' Conversion tool within ArcToolbox, but the added funbtionality of the tool will be that the user will also be able to specify if they would like the data (which is always an array of points if collected as lines or polygons) converted into line features or polygon features. I work in county government, and my intentions are to share this tool with users in different departments who regularly collect GPX data and would like the above functionality within the framework of a single script tool. I am currently having some problems with the code I have written. The script runs correctly until reaching the point in which a spatial reference object must be created with the correct projection, at which point i get the error: RuntimeError: ERROR 999999: Error executing function. Here is the code that I have so far:


import arcpy

import os

import sys

import traceback


# Set variables

GPX = arcpy.GetParameterAsText(0)   # User-specified GPX file

outlocGDB = arcpy.GetParameterAsText(1) # Output workspce to store GDB

fcnm = arcpy.GetParameterAsText(2)  # Name/location of the feature class that is to be created

##que = ##arcpy.GetParameterAsText(3)   # "Would you like to display you input GPX file as a Line Feature Class in ArcGIS?"

##que1 = ##arcpy.GetParameterAsText(4)  # "Would you like to display your input GPX file as a Polygon Feature Class in ArcGIS?"


# Create new File Geodatabase to store the output data

GDB = arcpy.CreateFileGDB_management(outlocGDB, "GPXFeatures")


outgdb = GDB.getOutput(0)     # Derive output of creation of File Geodatabase above


outfile = os.path.join(outgdb, fcnm) # output feature class for GPX to Features conversion


# Convert GPX files into features

arcpy.GPXtoFeatures_conversion(GPX, outfile)


# Set variables in preparation for projection operation

outprj = os.path.join(outgdb, str(fcnm) + "_prj")       # Create output name for projected version of above Feature Class

outSR = arcpy.SpatialReference("NAD_1983_StatePlane_Virginia_North_FIPS_4501_Feet")



arcpy.Project_management(outfile, outprj, outSR, "WGS_1984_(ITRF00)_To_NAD_1983")



Any sort of help would be greatly appreciated. Thanks so much.


-Jacob Snyder