In my current project, I am grabbing data from a web service and want to change the projection before inserting into a production db. For some reason when I am projecting the data, some of it is being lost. The point feature class is being projected just fine, but the polygon feature class created after calling arcpy.Project_management has no data in it. I've created sample code of the issue and hope somebody can shed some light.

import arcpy
import os

# scratch gdb and 2 feature classes (these are WGS84)
scratch_gdb = os.path.join("C:\\", "temporary", "scratch.gdb")
original_points = os.path.join(scratch_gdb, "original_points")
original_polys = os.path.join(scratch_gdb, "original_polys")

# remove rows from our feature classes

# add a point to the point feature class
point = arcpy.Point(-80.247928, 33.464786)
cursor = arcpy.da.InsertCursor(original_points, ['SHAPE@XY'])

# add a polygon to the polygon feature class
polyarray = arcpy.Array([arcpy.Point(-80.254769, 33.467541),
                         arcpy.Point(-80.239318, 33.468623),
                         arcpy.Point(-80.236017, 33.456030),
                         arcpy.Point(-80.264083, 33.451404)])
polygon = arcpy.Polygon(polyarray)
cursor = arcpy.da.InsertCursor(original_polys, ['SHAPE@'])

# at this point, both original_points and original_polys have data

# create path for 2 temporary feature classes
projected_points = os.path.join(scratch_gdb, "projected_points")
projected_polys = os.path.join(scratch_gdb, "projected_polys")

# delete these feature classes if they exist (from previously running the script)

# project our 2 old feature classes into our 2 new feature classes
sr = arcpy.SpatialReference(2273)
arcpy.Project_management(original_points, projected_points, sr)
arcpy.Project_management(original_polys, projected_polys, sr)

# projected_points has a point, but projected_polys has no rows ?

closed as unclear what you're asking by PolyGeo Sep 18 '18 at 7:02

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Never use arcpy.Polygon without specifying a SpatialReference, especially when the data is WGS84 -- this will truncate the coordinates to 3 or 4 places. You should always provide the closing vertex in the point array as well. – Vince Sep 5 '18 at 13:21
  • @Vince thanks for the reply. In the source data, the polygons do provide a closing vertex. That is just my mistake in the question. I did not know about the importance of providing a spatial reference to the polygon during creation, so I appreciate that tip! Unfortunately, this does not fix the overall issue. I really am stumped – jklaz Sep 5 '18 at 17:34
  • 1
    Did the point really get converted to 2273? Okay, I'm a terrible programmer, but I would try two things. You imply that you've confirmed that the input feature classes are fine. True? Second, I would comment out all the point-related code just to isolate the polygon code. Oh, third, if you make a polyline instead, does that work? – mkennedy Sep 5 '18 at 19:40
  • @mkennedy thanks for the suggestion. I tried it with a polyline, and the data again did not carry over. The layer properties in ArcMap show the that the Original (WGS84) and Projected (SC State Plane) layers for the point, line and polygon all do have the correct spatial references. Still not sure why the data is being lost – jklaz Sep 6 '18 at 12:35
  • Please revise your question with the current state of your code snippet. – PolyGeo Sep 16 '18 at 22:26