You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcCatalog Data Creation & Import/Export forum

create min bounding rectangle (mbr) table f...   Jeff Jensen May 27, 2008
Re: create min bounding rectangle (mbr) tab...   William Huber May 27, 2008
Re: create min bounding rectangle (mbr) tab...   Jeff Jensen Jun 18, 2008
Re: create min bounding rectangle (mbr) tab...   William Huber Jun 18, 2008
Re: create min bounding rectangle (mbr) tab...   Jeff Jensen May 27, 2008
Re: create min bounding rectangle (mbr) tab...   William Huber May 27, 2008
Re: create min bounding rectangle (mbr) tab...   Dan Patterson May 27, 2008
Re: create min bounding rectangle (mbr) tab...   Susannah O'Hanlon Aug 06, 2008
Re: create min bounding rectangle (mbr) tab...   jef duncan Apr 03, 2009
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject create min bounding rectangle (mbr) table from shapefiles 
Author Jeff Jensen 
Date May 27, 2008 
Message Hello ESRI Support,

Will you please help me extract the minimum bounding rectangle (xmin, xmax, ymin, ymax) from the shapefile for each and every polygon feature in it. Ideally I'll end up with a table that looks like this:

objectID,xmin,ymin,xmax,ymax

This is very similar to a raster catalog which can be created for images using ArcCatalog and a directory of all the images (aerial photos)

IMAGE,XMIN,YMIN,XMAX,YMAX

I', just trying to do the samething for polygon features.

Information on the minimum bounding box can be found here:
http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf#page=8
http://en.wikipedia.org/wiki/Shapefile

It appears from the above references the MBR is stored in the shapefile just like the area and perimeter of the polygon in stored in it. I'm hoping there is some object property I can reference using the Field Calculator in ArcMap (e.g. NewValue = Shape.Area)

Thanks for the help,

Jeff Jensen 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author William Huber 
Date May 27, 2008 
Message Jeff,

Sample Field Calculator code for computing XMIN appears below. Modify it in the obvious way to compute the other three parameters.

Information about shape properties appears in the "Geometry Object Model" diagram at http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeometry/GeometryObjectModel.pdf
 
dim Output as double
dim pGeom as IGeometry

set pGeom = [shape]
Output = pGeom.Envelope.XMin
 
  --Bill Huber
Quantitative Decisions (http://www.quantdec.com )
More GIS Q&A at http://gis.stackexchange.com/q/3083/664 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author Jeff Jensen 
Date Jun 18, 2008 
Message Hello Bill,

I'm trying to modify your code below to obtain the extent of the entire dataset using IGeoDataset::Extent. Will you please show I can use these objects in the Field Calculator. Below is my attempted which doesn't work:

Dim Output as Double
Dim pGeoDataset as IGeoDataset
Set pGeoDataset = [shape]
Output = pGeoDataset.Extent.Xmin

but getting VBA errors.

Thanks for the help,

Jeff 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author William Huber 
Date Jun 18, 2008 
Message Jeff,

A shape is not a GeoDataset, whence the failure.

It doesn't really make sense to use the Field Calculator to obtain properties of an entire layer, anyway: the FC only has access to properties of individual features.

You could write a script or, if this is a one-off calculation, just merge all the features into one and calculate the extent of that one shape. 
  --Bill Huber
Quantitative Decisions (http://www.quantdec.com )
More GIS Q&A at http://gis.stackexchange.com/q/3083/664 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author Jeff Jensen 
Date May 27, 2008 
Message Hello Bill,

Thanks for the excellent reply.

Will this solution also work for non-shapefile features as well, for example geodatabases?

Just to further clarify for the future readers, the IFeature interface "...gives you access to the spatial properties of a feature. One of these is the Extent property, which returns a feature's envelope. Every feature has an extent envelope that represents the smallest possible rectangle that can surround the feature." (Getting to Know ArcObjects by Robert Burke, p. 349)

Thanks again,

Jeff Jensen 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author William Huber 
Date May 27, 2008 
Message Jeff,

I haven't tested it, but in principle this approach will work with any feature table that can be edited. 
  --Bill Huber
Quantitative Decisions (http://www.quantdec.com )
More GIS Q&A at http://gis.stackexchange.com/q/3083/664 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author Dan Patterson 
Date May 27, 2008 
Message use http://arcscripts.esri.com/scripts.asp?eLang=&eProd=&perPage=10&eQuery=bounding+containers
with the extent and MABR options to ensure that the envelope is indeed the MABR (ie axis rotation optimized) and not the extent (not rotated but an EW NS rectangle) 
  Geomatics, Carleton University, Ottawa, Canada 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author Susannah O'Hanlon 
Date Aug 06, 2008 
Message Hi,

I have been trying to get 4 fields with xmin, xmax, ymin and ymax added to a shapefile.

The code given by William Huber works perfectly when I use this within the Field Calculator:

dim Output as double
dim pGeom as IGeometry

set pGeom = [shape]
Output = pGeom.Envelope.XMin

however I cannot export this to a python script - the line I am trying to run:

gp.CalculateField_management(species_shape, e, "Output", "VB", "dim Output as double\\ndim pGeom as IGeometry\\nset pGeom = [shape]\\nOutput = pGeom.Envelope.%s" %e)

falls down with VBA errors. I wondered if could just rewrite William's code in Python? The problem is I don't know ArcObjects, and find limited info on python access to ArcObjects - can python access the Envelope object? 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: create min bounding rectangle (mbr) table from shapefiles 
Author jef duncan 
Date Apr 03, 2009 
Message dan,

just downloaded and it works like a dream..

thanks