# How to get minimal rectangles from building footprints using Python

691
11
10-13-2019 08:13 AM
New Contributor II

hi, i have been working on to get minimum bounding rectangles for my building polygons using python. i do get square rectangles but i need minimum rectangles to train YOLOv3. need help with it. Thanks in advance.

11 Replies
MVP Esteemed Contributor
Esri Esteemed Contributor

Hi hassan.rg ,

I have branched your question to a new question since the OP was about Arcade and the GroupBy function.

Have you tried the option "Rectangle by width"? Does that change the result? See for options: Minimum Bounding Geometry—Data Management toolbox | ArcGIS Desktop

Frequent Contributor II

# Import arcpy module
import arcpy

#Circles being my polygon layer
# Local variables:
Circles = "Circles"
Circles_MinimumBoundingGeome = "C:\\Users\\<user>\\Documents\\ArcGIS\\Default.gdb\\Circles_MinimumBoundingGeome"

# Process: Minimum Bounding Geometry
arcpy.MinimumBoundingGeometry_management(Circles, Circles_MinimumBoundingGeome, "ENVELOPE", "NONE", "", "NO_MBG_FIELDS")

MVP Esteemed Contributor

rizwan gul‌, it helps if you explain what you are currently doing to get square rectangles, e.g., what geoprocessing tools or Python code.  Also, it is helpful if you can show an example (either screenshot or preferably data) that includes the footprint and current result.

New Contributor II

Hi, Joshua Bixby

i have got the python code. it gets me minimum bounding rectangles but only with given vertices not with polygons or point data. i am sharing it here. Error and screenshot is as under. i only can supply integer values to my function of Minimum rectangles not the polygon data. how i can extract all the values from polygon geometry into another variable as integer list? thank you

Moderator

Hi rizwan gul‌.

I see you have a duplicate version of this question in another space. In order to avoid duplicate questions and answer threads in different product places if you have a question that you'd like to share in multiple places then you can easily do this.

Follow the steps in this document Sharing Content with Multiple Places‌ and this will help keep everyone's answers in the same question thread whilst allowing you to share it to multiple places. This make it easier for other members to find and gain value from answered questions. Hope this helps.

Community Moderator, Esri Community Team.
Frequent Contributor II

Truthfully Louise ESRI needs to adjust the manner in which questions are structured in the question pane.

When the write gets to the selection to choose a location the instinct may be to select a group they feel matches what they are doing.

You may pick a group and see there are only 153 followers.  Well you may then think my question is only getting out to 153 people and that is if they log in on a regular basis.

It would quite possibly be a better practice to allow a person to select 2 or more groups, OR better yet have a basic general discussion option and a notice telling people this question is posted here here and link all the answers together.

Moderator

Thanks for your suggestion Robert to make this more intuitive for members. At this time with our current platform we are not able to change the way this functions but we'll certainly take this suggestion on board and look for opportunities to improve this in the future. For now sharing to multiple places is the best way to ensure a question gets wide exposure to the greatest audience without creating duplicate threads.

Community Moderator, Esri Community Team.
New Contributor II

I will check it next time, sorry for inconvenience.