create new shapefile in arcmap using python

感情迁移 提交于 2019-12-24 14:36:06

问题


I am trying to add a shape file in arc map without having the longitude and latitude but did not work . so how can i add new empty shape file in arcmap by using a simple python script ?


回答1:


If you just want a new shapefile, you can use arcpy.CreateFeatureClass_management. For example, if you want a new point data shapefile, you'd use something like

arcpy.CreateFeatureclass_management(r'C:\output', "points.shp", "POINT")



回答2:


Assuming if you are reading a text file with point coordinates. First step to creat feature class:arcpy.CreateFeatureclass_management(outputpath,fc,"Polygon").And create a insert cursor:cursor = arcpy.da.InsertCursor(fc,["shape@"]). Then obtain the points from text file and add them to an array to creat a polygon:

line_array = acrpy.Array()    
point = arcpy.Point()
for line in fileinput.input(infile):
    point.ID, point.X, point.Y = line.split()
    line_array.add(point)
polygon = arcpy.Polygon(line_array)
cursor.insertRow([polygon])
fileinput.close()
del cursor


来源:https://stackoverflow.com/questions/34752064/create-new-shapefile-in-arcmap-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!