2

I have a .dbf file and want to change it to a .shp file with its LAT/LON.

ArcPy Code,

import arcpy

arcpy.env.overwriteOutput=True
dbffile = "GIS_counts.dbf"

spref =  arcpy.SpatialReference(4326) #gcs_wgs_1984
arcpy.MakeXYEventLayer_management (dbffile, "LONGITUD", "LATITUDE", "test.shp", spref)

Error:

ERROR 000223: Cannot extract event table properties
Failed to execute (MakeXYEventLayer).

1 Answer 1

3

You will not be able to go directly from a dbf to a shp with that tool. The tool creates a feature layer as its output which is temporary, you then have to call a CopyFeatures to save the output as a shapefile. Have a look at the code sample in the online help documentation.

I think you will also need to create a table view of the dbf to use as input, so that the tool can correctly interpret the table.

Try making the following changes to your script:

import arcpy

arcpy.env.overwriteOutput=True
dbffile = "GIS_counts.dbf"

# Add
dbftable = arcpy.MakeTableView_management(dbffile, "dbftable")

spref =  arcpy.SpatialReference(4326) #gcs_wgs_1984

# Edit
arcpy.MakeXYEventLayer_management (dbftable , "LONGITUD", "LATITUDE", "xyLayer", spref)

# Add
arcpy.CopyFeatures_management("xyLayer", "test.shp")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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