You can use topojson.merge to do this, as shown in bl.ocks.org/5416405:
There are a few limitations to this approach (such as its dependence on an exact topology and lack of detection of holes), but it might for you as-is or with a few adjustments.
There is also the simpler approach of drawing the set of polygons for each region twice, once with a stroke and once with a fill, as shown in bl.ocks.org/5416440:
See also a very similar question on Stack Overflow.
Attach script
import arcpy, traceback, os, sys, math
from math import radians,sin,cos
from arcpy import env
env.overwriteOutput = True
inFC=arcpy.GetParameterAsText(0)
outFolder=arcpy.GetParameterAsText(1)
rectangle=r'in_memory\rectangle'
tempf=r'd:\scratch\many.shp'
def showPyMessage():
arcpy.AddMessage(str(time.ctime()) + " - " + message)
def ShapeMake(pGon,angle):
ar=arcpy.Array()
a=radians(angle)
part=pGon.getPart(0)
for p in part:
x,y=p.X,p.Y
xN=cos(a)*x+sin(a)*y
yN=-sin(a)*x+cos(a)*y
pN=arcpy.Point(xN,yN)
ar.add(pN)
pgonRotated=arcpy.Polygon(ar)
return pgonRotated
try:
arcpy.MinimumBoundingGeometry_management(inFC,rectangle,
"RECTANGLE_BY_WIDTH", "NONE", "", "MBG_FIELDS")
m,n=0,0
with arcpy.da.SearchCursor(rectangle, ("SHAPE@","MBG_Orientation")) as rows:
for row in rows:
shp,angle = row
onside=ShapeMake(shp,-angle)
extent=onside.extent
origPoint='%s %s' %(extent.XMin,extent.YMin)
yPoint='%s %s' %(extent.XMin,extent.YMax)
endPoint='%s %s' %(extent.XMax,extent.YMax)
if extent.width>extent.height:nRows,nCols=1,8
else:nRows,nCols=8,1
arcpy.CreateFishnet_management(tempf, origPoint,yPoint,
"0", "0", nRows, nCols,endPoint,
"NO_LABELS", "", "POLYGON")
arcpy.AddField_management(tempf, "Rotation", "DOUBLE")
arcpy.AddField_management(tempf, "Label", "Text", 25)
m+=1
with arcpy.da.UpdateCursor(tempf, ["SHAPE@","Rotation","Label"]) as rows:
for row in rows:
shp = row[0]
rollBack=ShapeMake(shp,angle)
row[0]=rollBack
row[1]=angle
m+=1
row[2]=str(m).zfill(8)
rows.updateRow(row)
n+=1
arcpy.CopyFeatures_management(tempf, '%s%sfnet_%s'%(outFolder,os.sep,str(n).zfill(4)))
except:
message = "\n*** PYTHON ERRORS *** "; showPyMessage()
message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
message = "Python Error Info: " + str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()
to tool:
Input feature layer:
Merge all shapefiles from Output Folder into single feature class shown below:
Best Answer
Ok, I had a go at this using existing tools for QGIS...
Download/enable the Buffer by percentage plugin from:
This creates buffers for each of your features.
Run this plugin on your layer and use the Buffer area percentage option. Enter
20
(for 20%), save the output and run it again for40
,60
, and80
.Here is an example layer:
And here is running the plugin:
And here are the results of the plugin (it will help to add the percentage value in the name as we will use this to identify the layers):
Now we need to run this really ugly model (or you can download it and copy it to your
/.qgis2/processing/models
folder):When you run it, you will need to enter the correct layers according to parameter (hence why we need to include the % value in the name):
The output should hopefully have split your features into five equal parts. I tested this on several areas and calculated the area using the Field Calculator with the expression
$area
. Although it might not look attractive to what you wanted in your image, it does seem to split the features equally...