Like I have a rectangle (3x5m) as a vector layer... now I would like to fill this 3x5m rectangle optimal with smaller polygons in a given shape (1x2m rectangles).

I didn't find anything helpful yet....

Like I have a rectangle (3x5m) as a vector layer... now I would like to fill this 3x5m rectangle optimal with smaller polygons in a given shape (1x2m rectangles).

I didn't find anything helpful yet....

- 3 people found this helpful
Andreas,

There is a tool called "create fishnet" in the Data Mangement Tools > Feature Class > Create Fishnet

You can specify the Template Extent as your 3m x 5m rectangle and then set the Cell Size Widget to 1m and Cell Size height to 2m and leave Number or Rows and Columns black. This will create a new FC with cells that are 1m by 2m.

Do you only want one 1 x 2 polygon in the 3 x 5?

If you want to completely fill the polygon you would need to change the size of your 1 x 2's as the result would not be the same area, either a 1 x 2 would be cut down or exceed the boundary. You could stack 1 x 2's 3 high but would either need to go 4 or 6 wide

If you only want to create a single 1 x 2 in the middle of the 3 x 5 that's an easy fix.

It is far easier to create the bounds and orientation at the smaller scale, then aggregate them to the larger unit, than to ensure that everything fits within those bounds. Sort of like squeezing stuff into a package... it is easier to wrap what exists than to put something into a pre-existing container.

I would like to place "the maximum nr" of 1x2 polygon in this space, not completely fill the polygon... means, in this example it should not place more polygons cause as you said, this would be an exceed of the boundary..

The nr. of the given polygons should not matter, nor the size/shape...

I'm looking for an solution / feature like:

-check all polygons of layer A

-Fill each polygon of layer A with the max. possible nr of polygons 1x2mgood luck... their is a body of literature out their which goes by several names... polygon packing .... is one. The problem isn't simple, particular since their size and shape is not fixed. For rectangular bodies, you can translate and orient the rectangle to the XY plane centered about the origin, then use X, Y subdivision to produce you packing.

For example, consider a polygon translated and oriented to the 0,0 origin ( a rigid affine transformation, just translation and rotation). A rectangle with a width of 10 and a height of 6 will have its center at 0,0 and the left and right edges at -5 and +5, and top and bottom at 3 and -3. It is simple math to figure out how to slice the polygon into chunks or rectangles in the X and or Y plane. Other shapes will be more complicated, but the affine transformation will put it into the best position to be subdivided.

I will be interesting to see what you come up with

Thank you Robert, I tryed to do it with the gridindexfeature. Works kind of, except (as you said) for the North-South arrangement...and the arrangement is very important

So far it is the best solution but I still not what I try to find...

I'll try to find out how to get the generated gridindex into the right arrangement.... What i further have is the aspect of the "to be filled polygons"..

so maybe I can integrate this aspect into the gridindex ?!...Still thankful for your help

And if I find out something I'll let you know here

- 3 people found this helpful
Hi, see if this gets you close:

http://arcgis.com/home/item.html?id=9398bd2232cb4c8490b0b05015364d28

- 2 people found this helpful
Here's my attempt. It's not necessarily the optimal. You could rotate the grid axes and compare to see which holds the most rectangles. There is also the distinct possibility that neither orientations optimally fill the original rectangle (i.e. there is often a remainder that could fit more small rectangles rotated by 90 degrees).

`recs = 'recs' # rectangle feature layer`

mbr = arcpy.MinimumBoundingGeometry_management(recs,r'in_memory\mbr',mbg_fields_option='MBG_FIELDS') # get MBRs

grids = [] # merge list to be populated

out_grid = r'in_memory\out_grid' # final output

sr = arcpy.Describe(recs).spatialReference # CRS

grid_h = 20 # cell height, aligned to long axis of rectangle

grid_w = 10 # cell width, aligned to short axis of rectangle

with arcpy.da.SearchCursor(mbr,['SHAPE@','OID@','MBG_Width','MBG_Length','MBG_Orientation'], spatial_reference=sr) as cursor:

for row in cursor: # loop through MBRs

grid = r'in_memory\grid_' + str(row[1]) # temp grid

dy = math.cos(math.radians(row[4])) * row[3] # y diff along long side

dx = math.sin(math.radians(row[4])) * row[3] # x diff along long side

y_axis = str(row[0].firstPoint.X + dx) + ' ' + str(row[0].firstPoint.Y + dy) # rotation point

origin = str(row[0].firstPoint.X) + ' ' + str(row[0].firstPoint.Y) # starting point

arcpy.env.outputCoordinateSystem = sr # set CRS for fishnet

arcpy.CreateFishnet_management(grid,origin,y_axis,grid_w,grid_h,int(row[3]/grid_h),int(row[3]/grid_w),labels='NO_LABELS',geometry_type='POLYGON') # make fishnet

temp_lyr = 'sel_' + str(row[1]) # temp layer

arcpy.MakeFeatureLayer_management(grid,temp_lyr) # make feature layer

arcpy.SelectLayerByLocation_management(temp_lyr,"WITHIN_CLEMENTINI",row[0],selection_type='NEW_SELECTION') # select grid cells inside MBR

arcpy.SelectLayerByAttribute_management(temp_lyr,"SWITCH_SELECTION") # switch selection

arcpy.DeleteFeatures_management(temp_lyr) # delete cells outside MBR

grids.append(grid) # add to merge list

arcpy.Merge_management(grids,out_grid) # merge

Andreas,

Try the Minimum Bounding Polygon tool:

Creating a minimum bounding rectangle—Help | ArcGIS for Desktop