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.


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()            
    polygon = arcpy.Polygon(array)

arcpy.Buffer_analysis(polygon, "poly_buffer", "150 METERS")    
arcpy.analysis.Erase("poly_buffer", polygon, "polygon2")
  • 1
    arcpy doesn't display geometry, you need to add it to a map and make it visible How are you running the code? And which geometry are you expecting to display - featureclass, polygon, poly_buffer and/or polygon2?
    – user2856
    Commented Jan 19, 2022 at 4:48
  • 3
    Even though it is optional, you should never use ArcPy Geometry constructors like Polygon without a spatial_refetence parameter. Failure to do this can result in the coordinate values being clipped to four decimal places.
    – Vince
    Commented Jan 19, 2022 at 11:37

1 Answer 1


First of all take heed of @Vince's warning about using a spatial reference in the construction of the geometry, not doing what he suggests is shooting yourself in the foot.

As @user2856 suggests its unclear what you want to display, you add LAYERS to a map not a single geometry.

I'm assuming you are running this code from the python console inside ArcGIS Pro. If you are running it in an IDE then you would never expect it to add a layer to an active instance of ArcGIS Pro.

So if you are running your code in the python console then looking at setting the addOutputsToMap environment property.

Also check you have not turned off add to display in the geoprocessing application settings of ArcGIS Pro.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.