Thursday, 6 September 2018

arcgis desktop - Increase each polygon area to the same area



enter image description hereI'm using ArcGIS Desktop 10.2.


I have many polygons (buildings) with various areas and I want the same area for all my polygons: 100m². The final goal is to aggregate them and build the urban agglomeration.


I was thinking of creating a buffer with a value for each polygon and using the field value to generate the buffer, but the challenge is to find the value.



Answer



Similar to this question, your task doesn't have analytical solution. Fortunately an accurate estimate can be found numerically through iterations and by using root-finding techniques.


Create a copy of your buildings, call it "polygons" in active mxd table of content and run this script:


import arcpy
target,tolerance=500,0.001
maxR=pow(target/3.141593,0.5)


mxd = arcpy.mapping.MapDocument("CURRENT")
buffers = arcpy.mapping.ListLayers(mxd,"POLYGONS")[0]
with arcpy.da.UpdateCursor(buffers,"SHAPE@") as cursor:
for i,row in enumerate(cursor):
shp=row[0]; area=shp.area
arcpy.AddMessage('Processing polygon No %i'%i)
if area>=target:continue
low,high=0,maxR
while True:
middle=0.5*(low+high)

newPgon=shp.buffer(middle)
if (high-low) curArea=newPgon.area
if curArea else:high=middle
cursor.updateRow((newPgon,))

OUTPUT:


enter image description here


Note: you need to modify target value, e.g. change it to 100. Script tested on shapefile, you have to start editing session, if "polygons" stored in database, so that ArcGIS will be able to recalculate Shape_Area field. The accuracy of solution only depends on ArcGIS ability to compute buffer.



It took under 2 seconds to complete task for 95 polygons shown on my very old PC.


No comments:

Post a Comment