I have a series of CSV files that I need to convert to point feature classes. I have the following code :

# Convert CSV file to raster
import arcpy
workspace = "Y://DEM250m//CSV_Points"
arcpy.env.workspace = workspace # Set environment settings
mycsvs = arcpy.ListFiles("*1980-2010.csv") # Access all historical data

sr = arcpy.SpatialReference()

# Convert CSV to point featureclass
out_table = "Y://DEM250m//CSV_Points//Historical"
for i in mycsvs:
        workspace + "//" + i,
        out_table + "//" + i, 

I have tried many variations of the following:

arcpy.SpatialReference('WGS 1984')

It never seems to want to project my csv data correctly (it always seems to show up in the middle of the ocean around the equator). I have checked what a lot of other people have posted about here before and tried those solutions, but they never seem to work for me.

What am I doing wrong?

I have added an image of what the relevant CSV columns look like.

enter image description here

  • The tool's help page talks about When the Z Field parameter is specified, the default coordinate system also includes the WGS 1984 vertical coordinate system. If the z-values are not in meters, modify the coordinate system to use the correct elevation unit.. Most probably your sr definition is incomplete. You can try arcpy.SpatialReference(4326, 3855).
    – fatih_dur
    Sep 17, 2021 at 6:57
  • Hi fatih_dur, I just tried your recommendation and it still threw my points in the middle of the ocean. Also, the z values are in meters.
    – Burnz
    Sep 17, 2021 at 15:43

1 Answer 1


You have an error in your code where you are supplying your coordinates in the sequence of Latitude (Y) then Longitude (X). Look at the tool's help page and you we see that the tool requires Longitude (X) then Latitude (Y).

My test data was a folder of just one csv so you'll need to adjust your code accordingly, but this worked for me:

import arcpy
arcpy.env.overwriteOutput = True
workspace = r"C:\Scratch"
arcpy.env.workspace = workspace # Set environment settings    
mycsvs = arcpy.ListFiles("*.csv") # Access all historical data    
sr = arcpy.SpatialReference(4326)

# Convert CSV to point featureclass
out_table = r"C:\Scratch"
for i in mycsvs:
    arcpy.management.XYTableToPoint(workspace + "//" + i,out_table + "//test2.shp",'Longitude','Latitude','Elevation',sr)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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