Polygon to Point

Blog Post created by johnmdye on Oct 11, 2017

Converts an input Polygon Featureclass to a Point Feature Class, maintaining data schema and all values. There are a couple of different ways to do this already and Esri's Feature to Point tool can certainly do this - but that tool is licensed only at ArcGIS Advanced/ArcInfo. 

import arcpy  
import os 
workspace = "" 
polyFC = "" 
pointFCName = "" 
# Create the Point Featureclass using the polyFC as a template to define the 
# schema for the pointFC 
                               , pointFCName 
                               , "POINT" 
                               , polyFC 
                               , "SAME_AS_TEMPLATE" 
                               , "SAME_AS_TEMPLATE" 
                               , arcpy.Describe(polyFeatures).spatialReference) 
pointFC = os.path.join(workspace, pointFCName) 
# Create a list of all of the fields in the Polygon Featureclass except for 
# the Shape fields which we don't want 
polyFields = [ for field  
              in arcpy.ListFields(polyFC)  
              if not in ["SHAPE", "SHAPE_Length", "SHAPE_Area"]] 
if not polyFields == pointFields: 
    raise Exception("Polygon and Point Schemas do not match") 
# Create a list of all of the fields in the Point Featureclass except for 
# the Shape field we we don't want yet because we want to add it manually to 
# ensure it is in at the end of the list 
pointFields = [ for field 
               in arcpy.ListFields(pointFC) 
               if not in ["SHAPE"]] 
# Add the 'SHAPE' field to the end of the pointFields list ensuring it is at 
# the end of the list 
# Add the 'SHAPE@XY' token to the end of the polyFields list so that we can  
# retrieve the centroids 
# Set up SearchCursor to iterate on the polyFC 
with arcpy.da.SearchCursor(polyFC, polyFields) as polyCursor: 
    # Set up an InsertCursor to iterate on the pointFC: 
    with arcpy.da.InsertCursor(pointFC, pointFields) as pointCursor: 
        # for each record in the polyFC 
        for poly in polyCursor: 
            # Add the record