[GIS] Create Feature Class From XY Table Using Python

arcgis-10.2arcgis-desktoparcmapfeature-classpython

I have some txt files that are basically attribute tables (object ID, latitude, longitude, area). In ArcMaps, I have been converting these files into feature classes and saving them in a geodatabase using the following steps:

  • Right click file

    Create Feature Class > From XY Table

    Click on the Coordinate System of Input Coordinates button and then
    select coordinate system

    Save as File and Personal Geodatabase feature classes and output to
    selected geodatabase

Since I have a large number of files, I'd like to script this using Python. I don't have a problem iterating throuygh the file folder and getting a list of all files, but which function from the ARC Python library should I use? The is Create Feature Class tool the best one I've been able to find so far, but it created an empty feature class.

i have tried opening the Geoprocessing > results tab while creating the feature class manually, so that I can copy as script, but for these actions I am not seeing any entries in the result pane.

Best Answer

You make no mention that you have any problems reading your text file, so I am assuming that it is just how to get the coordinates into a feature class that has you stumped.

There are a number of ways to do this so some suggestions to start looking at are:

Both have code examples that I think should get you past where you are stuck. I recommend getting the code samples to work first and then try to apply to your situation second.