Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python在arcmap中创建新的shapefile_Python_Gis_Arcmap - Fatal编程技术网

使用python在arcmap中创建新的shapefile

使用python在arcmap中创建新的shapefile,python,gis,arcmap,Python,Gis,Arcmap,我试图在没有经度和纬度的情况下在arc map中添加一个形状文件,但没有成功。那么,如何使用简单的python脚本在arcmap中添加新的空形状文件呢?如果您只需要一个新的形状文件,可以使用。例如,如果需要新的点数据形状文件,可以使用 arcpy.CreateFeatureclass_management(r'C:\output', "points.shp", "POINT") 假设您正在读取具有点坐标的文本文件。创建要素类的第一步:arcpy.CreateFeatureclass_manag

我试图在没有经度和纬度的情况下在arc map中添加一个形状文件,但没有成功。那么,如何使用简单的python脚本在arcmap中添加新的空形状文件呢?

如果您只需要一个新的形状文件,可以使用。例如,如果需要新的点数据形状文件,可以使用

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

假设您正在读取具有点坐标的文本文件。创建要素类的第一步:arcpy.CreateFeatureclass_management(outputpath,fc,“Polygon”)。并创建插入光标:cursor=arcpy.da.InsertCursor(fc,[“shape@]”)。然后从文本文件中获取点并将其添加到阵列中以创建多边形:

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

欢迎来到SO!分享你迄今为止的尝试。由于您的问题在于您尝试过的代码,请共享相关代码。