How to get the Width/Height of Rectangle in Arobjects of VBA

1139
8
05-03-2010 06:35 AM
jessieleo
New Contributor
Hi,

How to get the Width/Height of Rectangle in Arobjects of VBA. please see the attached picture.

Thank you.

Jessie
0 Kudos
8 Replies
JohnHauck
Occasional Contributor II
Is this a feature in a feature class? ArcObjects provide many classes for working with and getting information about geometries but the geometries have to be defined in the correct way. Please provide some additional details.
0 Kudos
jessieleo
New Contributor
yes, it is feature in a polygon feature class. I didn't find which Interface can fogure out the width/Hight of a rectangle.

Thanks

jessie
0 Kudos
jessieleo
New Contributor
Is this a feature in a feature class? ArcObjects provide many classes for working with and getting information about geometries but the geometries have to be defined in the correct way. Please provide some additional details.





yes, it is feature in a polygon feature class. I didn't find which Interface can figure out the width/Height of a rectangle .
Note: it is rectangle with any rotation instead of Envelop.


Thanks

jessie
0 Kudos
EricPaitz
Esri Contributor
Interesting problem. I assume you have more then one to calculate? You have a whole table full of rotated envelopes? Does each feature know its rotation angle? If so they you can rotate them back to 0 or 90 degrees with the ITransform2D and then get its width and height.

Another idea...if you know that there are 4 vertices that make up your polygon (plus a 5th to close the polygon) you can calculate the distance between vertex 0 and 1 and then calculate the distance between vertex 0 and 3 and that should give you the rotated width and height.
0 Kudos
jessieleo
New Contributor
Thank you.
It works for your option 1. Option 2 not working due to there are more than 5 points in a polygon.

Jessie
0 Kudos
AndrewHansford
Occasional Contributor II
Good Afternoon,

I was wondering, would it be possible to calculate the width and height of a polygon in ArcGIS 10 to eliminate slithers of polygons as the width should be smaller than the height of a polygon possibly.

Would be great to hear from you regard this...

Regards
0 Kudos
AlexanderGray
Occasional Contributor III
The problem depends on what you consider width and height. 

Technically speaking, with complex polygons, there is not such thing as height.  There is the longest diagonal and perhaps the complement diagonal.  If your polygon has only four vertices than it becomes a tetragon or quadrilateral, if all the angles are 90 degrees it is a rectangle.  If you can reduce your polygons to 4 vertices (taking out vertices where the angle is close to 180 degrees for example) you can get a rectangle or a pseudo rectangle if the angles are close enough to 90.  Once you have a rectangle, pick any corner and calculate the distance to the next vertex and to the previous vertex (a line between two vertices is a ILine).  That should get you width and height.  If you have large polygons near one of the poles, depending on the coordinate system you would get different results depending on which vertices you start with, perhaps an average would be appropriate.  As to which is the width and height, that depends on you definition of them (longest, most north-south, perpendicular to a road, etc.)
0 Kudos
AlexanderGray
Occasional Contributor III
As for sliver polygons, I find the area to perimeter (length) ratio to be the best.  Slivers tend to be bellow an area threshold and have a low area to length ratio.
0 Kudos