Whats the easiest way to move one geometry to the center of another geometry? That attribute is read only. Im generating polygons and writing them out to a row in a script. Right now the first point of my geometry object is the centroid of a parcel which means the drawings intersect the correct parcel but are not centered on it. I just tried adding the difference between the parcel centroid and the geometry centroid but while that moved the new geometry it didnt move it to the centroid as I had hoped. Below is what I tried, parcelLookup is a nested dictionary that has all of the parcel numbers with their centroids.def addGeometry(inGeometry,parcelID,buildingNum,row): diffX = (parcelLookup[parcelID]['x'] - arcpy.Geometry('polygon',inGeometry).centroid.X) diffY = (parcelLookup[parcelID]['y'] - arcpy.Geometry('polygon',inGeometry).centroid.Y) for i in range(0,inGeometry.count): oldPoint = inGeometry.getObject(i) newPoint = arcpy.Point(oldPoint.X + diffX, oldPoint.Y + diffY) inGeometry.replace(i,newPoint) row.shape = arcpy.Geometry('polygon',inGeometry) row.PID = parcelID row.Id = buildingNum rows.insertRow(row)
Edit: I was subtracting the centroid of the parcel from the centroid of the geometry. Thats backwards. Subtracting the geometry from the parcel is the right order. Cursed be all typos.