Select to view content in your preferred language

How to create the maximum rectangle in a polygon using python?

3063
4
11-26-2020 06:39 PM
wlew
by
Emerging Contributor

Hi, I am using Arcgis Pro 2.4.2 and I am trying to generate the maximum rectangle within a polygon which should have an area of 60% of the original polygon. 

I am totally new to Arcgis Pro and I am not sure if I can use arcpy to do it within Arcgis Pro, any suggestions or guidance here would be much appreciated.

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

This is an ugly problem.

  • does the rectangle have to be axis aligned? (ie. parallel to the x/y axes)
  • are the polygons convex or concave
  • the 60% factor ... how fast is that requirement? do you mean 60% or more? 60% or less?
  • what is the actual rectangle area you are interested in? is there a minimum or maximum size?

If you can articulate your requirements, perhaps alternate solutions can be suggested.

I suggest you do some reading on the topic:

Project with visuals 

Largest inscribed rectangles in convex polygons - ScienceDirect

[1905.13246] Largest Inscribed Rectangles in Geometric Convex Sets (arxiv.org)

(PDF) Computing the Largest Inscribed Isothetic Rectangle (researchgate.net)


... sort of retired...
wlew
by
Emerging Contributor

Hi Dan,

- The rectangle has to be orientated to North(0 degrees), or aligned to the nearest road.

- It has to be a convex one but in my opinion concave/convex doesn't matter if an algorithm is written

- The rectangle has to fill up 60% of the original polygon's area

I have attached a visual of this rectangle in polygon feature that I hope to achieve

0 Kudos
wlew
by
Emerging Contributor

Hi Manish,

Thank you for you reply. I have seen this post before, but I ran into issues running the example code that was provided in one of the answers.

return convertArcObjectToPythonObject(getattr(self._arc_object, attr_name))
SystemError: <built-in function getattr> returned NULL without setting an error

 

This error seems to be an issue with _base.py and I can't figure out what went wrong

0 Kudos