"Everything is related to everything else, but near things are more related than distant things"
Create Polygon
The Python scipt creates a new polygon feature class containing a single ( square ) polygon with the following coordinates: ( 0, 0 ), ( 0, 1,000 ),(1,000, 0), and ( 1,000, 1,000 ).
# Ehsan Momeni
import arcpy
import fileinput
import string
from arcpy import env, da, Array
env.workspace = r"C:\Users\emomeni\" # workspace
env.overwriteOutput = True
infile = r"C:\Users\emomeni\Coordinates.txt" # coordinate files
outpath = r"C:\Users\emomeni\\" # output path
newfc = "Polygon.shp" # new shapefile name
arcpy.CreateFeatureclass_management(outpath, newfc, "POLYGON") # creating new shapefile
cursor = da.InsertCursor(newfc, ["SHAPE@"]) # inserting coordinates
array = Array()
for line in fileinput.input(infile):
ID, X, Y = string.split(line," ")
array.add(arcpy.Point(X, Y))
cursor.insertRow([arcpy.Polygon(array)])
fileinput.close()
del cursor