Skip to main content
deleted 12 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

You have done a "school boy error",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)

You have done a "school boy error", in your code 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)

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)
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84

You have done a "school boy error", in your code 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)