I'm having an issue displaying a geometry in ArcPy. I'm not sure if it's my code or if it's a setting in ArcGIS Pro. The code runs successfully yet does not display the geometry.
Thoughts?
I was in ArcGIS Pro but I couldn't find it on the map. It would add it to the layers BUT I managed to find it on the map when I clicked on "Center on" with a right click on the layer in the contents.
# Add python codes here
import fileinput, os
import arcpy
from arcpy import env
env.workspace = "module_four_testing.gdb"
env.overwriteOutput = True
infile = 'square.txt'
featureclass = 'square'
arcpy.CreateFeatureclass_management("module_four_testing.gdb", featureclass, "Polygon")
with arcpy.da.InsertCursor(featureclass, ["SHAPE@"]) as cursor:
array = arcpy.Array() # Creating the array for storing all Point objects.
point = arcpy.Point() # Creating a Point object for one vertice.
for line in fileinput.input(infile):
point.ID, point.X, point.Y = line.split()
array.add(point)
polygon = arcpy.Polygon(array)
cursor.insertRow([polygon])
fileinput.close()
arcpy.Buffer_analysis(polygon, "poly_buffer", "150 METERS")
arcpy.analysis.Erase("poly_buffer", polygon, "polygon2")
featureclass
,polygon
,poly_buffer
and/orpolygon2
?Geometry
constructors likePolygon
without aspatial_refetence
parameter. Failure to do this can result in the coordinate values being clipped to four decimal places.