I have a table (.dbf table) and I need to display on map its values. In this table I have fields: Value to display, longitude(at meters), latitude (at meters). When I right click in this layer and select display xy data, it works but I need to use Python to do this in order to use an automatically tool.
So I used make XY event layer with Arcpy:
import arcpy, sys, string, os
arcpy.env.workspace = r"path\to\work\area"
in_Table_GR = r"F:\ArcGIS\Trab\Model\Result_ot\Ge_P_R_Sub_Otim.dbf"
in_y_GR = "Latitude"
in_x_GR = "Longitude"
out_Layer_GR = "P_r_g_otim"
spref = arcpy.SpatialReference(102164)
arcpy.MakeXYEventLayer_management(in_Table_GR, in_x_GR, in_y_GR, out_Layer_GR, spref)
And it gives me an error:
Runtime error Traceback (most recent call last): File "<string>", line 1280, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6381, in MakeXYEventLayer raise e ExecuteError: ERROR 000212: Cannot create XY event source Failed to execute (MakeXYEventLayer).
And if I execute function MakeXYEventLayer manually I get the same error. It only work's if I use "display xy data" when I click on this layer.
What is the problem and how can I solve this?