How can we determine minimum bounding rectangle in Arcgis?

4558
10
Jump to solution
02-22-2016 11:21 PM
Hemant_SinghRathore
New Contributor II

If we have multiple polygons and we want to calculate the minimum bounding rectangle, how can we do this?

In the native iOS it's done http://stackoverflow.com/questions/1303265/algorithm-for-determining-minimum-bounding-rectangle-for-...

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DiveshGoyal
Esri Regular Contributor

To get min bounding rectangle of a bunch of geometries, you should union them together using the geometry engine - 10.2.5: AGSGeometryEngine Union

You can then use the envelope of the resulting geometry  

View solution in original post

10 Replies
XanderBakker
Esri Esteemed Contributor

I haven't worked with the Runtime SDK for iOS, but I just had a look at the documentation and the 10.2.5: AGSPolygon Class Reference has a property envelope that returns a 10.2.5: AGSEnvelope Class Reference . I would have expected to find methods for the union of envelopes, but for some reason I only see methods for intersecting envelopes. Anyway, you can use the methods provided in the page you referenced,  extracting the xmin, ymin, xmax, ymax properties of the AGSEnvelope.

Hemant_SinghRathore
New Contributor II

Yes I have already tried that and I was able to get the min and max value but while plotting those values on the arcgis map.
Map is throwing the below exception:

libc++abi.dylib: terminating with uncaught exception of type Esri_runtimecore::Common::Out_of_range_exception: Out of range

0 Kudos
XanderBakker
Esri Esteemed Contributor

As mentioned before I have no experience with the Runtime SDK for iOS, but I would verify the spatial reference of the map, the envelope and polygons. I you are inserting projected coordinates (large values) and these are being interpreted as geographic coordinates, this may cause these type of problems. Or if for some reason a value is not set of the output bounding envelope, this could also be the cause. Have you verified the values?

0 Kudos
Hemant_SinghRathore
New Contributor II

Xander Bakker​ Thanks for your help.
Yes i have debug the values and my code is correctly converting the coordinates into Arcgis coordinates.
I guess my code is correctly getting the min and max coordinates but due to some reason code is throwing exception while using those values with Arcgis.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Can you list the values you obtain and the spatial reference? I think this info might be helpful for someone with knowledge of the SDK to see what might be going wrong.

0 Kudos
Hemant_SinghRathore
New Contributor II

Here are the values x = 8435479.317740, y = 2595778.804307, spatial reference: [AGSSpatialReference: wkid = 3857]

0 Kudos
XanderBakker
Esri Esteemed Contributor

Coordinates look normal, they point to Indore India for the WGS_1984_Web_Mercator_Auxiliary_Sphere projected coordinate system. You mention that you are converting the coordinates into ArcGIS coordinates. What do you exactly mean by that?

The spatial reference you mentioned applies for the map and the polygon layer?

Another question; if the polygons reside in the same featureclass (layer) does the fullEnvelope property in the 10.2.5: AGSLayer Class Reference not work for you?

0 Kudos
Hemant_SinghRathore
New Contributor II

Thanks for your help Xander Bakker​, reply from Divesh worked for me.

0 Kudos
DiveshGoyal
Esri Regular Contributor

To get min bounding rectangle of a bunch of geometries, you should union them together using the geometry engine - 10.2.5: AGSGeometryEngine Union

You can then use the envelope of the resulting geometry