workspace = ".../file.gdb" testShape = ".../test_graphics" dBufDis = -10 g = arcpy.Geometry() geometryList = arcpy.Buffer_analysis(testShape, g, dBufDis) for geometry in geometryList: print geometry.area
rows = arcpy.SearchCursor(testShape) for row in rows: g = arcpy.Geometry() rowShape = row.getValue(shapeName) arcpy.Buffer_analysis(rowShape, g, dBufDis)
Script: ' ---- You may need to adjust these values ---- Const PCNT_RED As Double = 20 Const PCNT_TOL As Double = 0.001 ' --------------------------------------------- Const NUM_FMT = "0.0##############" Dim dMinArea As Double Dim dMaxArea As Double Dim dMinDis As Double Dim dMaxDis As Double Dim dBufDis As Double Dim pEnv As IEnvelope Dim pPoly As IPolygon Dim dPolyArea As Double Dim pTopOp As ITopologicalOperator Dim pBuffer As IPolygon Dim pArea As IArea Dim dBufArea As Double ' Get a ref to the polygon Set pPoly = [Shape] Set pTopOp = pPoly pTopOp.Simplify ' Calc valid area range Set pArea = pPoly dPolyArea = pArea.Area dMinArea = dPolyArea * (1 - (PCNT_RED + PCNT_TOL) / 100) dMaxArea = dPolyArea * (1 - (PCNT_RED - PCNT_TOL) / 100) ' Calc min/max/initial bufferdis Set pEnv = pPoly.Envelope With pEnv If .Width > .Height Then dMaxDis = .Width / 2 Else dMaxDis = .Height / 2 End If End With dMinDis = -dMaxDis dBufDis = (dMinDis + dMaxDis) / 2 ' Get the buffer Set pBuffer = pTopOp.Buffer(dBufDis) ' Iterate through adjusting the buffer until we get a value ' within our agreed range or until we get as close as possible Do While Format(dMinDis, NUM_FMT) <> Format(dMaxDis, NUM_FMT) ' Check buffered area is within valid range Set pArea = pBuffer dBufArea = pArea.Area If dBufArea >= dMinArea And dBufArea <= dMaxArea Then Exit Do ' Check if we have a negative area If dBufArea < 0 Then ' We have, so just use the original polygon Set pBuffer = pPoly Exit Do End If ' Readjust buffer distance If dBufArea < dMinArea Then dMinDis = dBufDis Else dMaxDis = dBufDis End If dBufDis = (dMinDis + dMaxDis) / 2 ' Generate the buffer from adjusted distance Set pBuffer = pTopOp.Buffer(dBufDis) Loop ' Use pBuffer in box below Advanced Window
Hi Christian - did you find a tool or rewrite this VBA script in Python? I am also interested in creating polygons within polygons based on a percentage reduction. Please let me know. Cheers, Bill