1. 程式人生 > >arcpy根據txt建立點圖層

arcpy根據txt建立點圖層

sr = arcpy.SpatialReference(4326)
fc=arcpy.CreateFeatureclass_management( r"D:\cs","test.shp", "POINT", "", "","", sr)
arcpy.AddField_management(r"D:\cs\test.shp", "leibie", "TEXT")
cursor=arcpy.InsertCursor(fc)
for line in cent:
    feature = cursor.newRow()
    # Add the point geometry to the feature
    vertex = arcpy.CreateObject("Point")
    vertex.X = line[0]
    vertex.Y =line[1]
    feature.shape = vertex
    # Add attributes
    feature.leibie = "shumu"
    # write to shapefile
    cursor.insertRow(feature)
del cursor
del fc