I have a shapefile that consists of one polygon whose boundary is defined by a large number of points. Whoever originally made the file inverted the latitude and longitude coordinates, so the data displays at 38 degrees east of Greenwich and 122 degrees south of the equator, which is well south of the south pole, or off in space, or somewhere on the imaginary number line, or something. How can I fix this? I could make another shapefile and manually enter the correct coordinates, but this particular polygon is defined by several hundered vertices so I would rather not do it that way. Is there a python script or GP tool that can help me?
You can do it easily with Python. You can do the following in ArcMap's Python Window:
with arcpy.da.UpdateCursor("your_layer_name", ['SHAPE@XY']) as rows: for r in rows: rows.updateRow((r[::-1],))
You'll need to refresh the active view afterwards. You can do that with the refresh button or
arcpy.RefreshActiveView(). Then you should see the points shift.
Just reread your question again. If you want to skip the point adjustment, and reverse the coordinates for all the vertices of the polygons themselves, the code becomes slightly more complicated but retains the same general principal:
with arcpy.da.UpdateCursor("your_layer_name", ['SHAPE@']) as rows: for r in rows: # reverse points within polygon (supports multipart polygons as well) rows.updateRow((arcpy.Polygon(arcpy.Array(arcpy.Array([arcpy.Point(p.Y, p.X) for p in part]) for part in r)),))