# Compute the longest radius in a polygon

300
8
01-21-2022 06:52 PM
Labels (1)
New Contributor III

Hello. I'm using ArcGIS Pro 2.9.0. I have more than 6,000 census block groups (polygons in ArcGIS Pro) and I would like to compute the longest radius in each of them. I attached a picture to illustrate what the longest radius is. I would really appreciate it if you could let me know how I could accomplish it. Thank you.

Tags (3)
2 Solutions

Accepted Solutions
by
Esri Regular Contributor
MVP Esteemed Contributor

I agree with Dan but... If your requirement is to have the line not cross any boundaries, it will not produce the expected results if your polygons are concave and not convex.  If your shapes were regular geometric figures and convex it wouldn't be an issue

... sort of retired...
8 Replies
by
Esri Regular Contributor
MVP Esteemed Contributor

I agree with Dan but... If your requirement is to have the line not cross any boundaries, it will not produce the expected results if your polygons are concave and not convex.  If your shapes were regular geometric figures and convex it wouldn't be an issue

... sort of retired...
New Contributor III

Hello Dan. Thank you for your reply. I used the Minimum Bounding Geometry tool and chose Convex hull as the geometric type. It does the job. One thing is that the MBG length is in a very weird unit. So I would like the distance to be measured in mile. A distance that should have been 0.6 mile is displayed as 0.009411 in ArcGIS Pro. https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/minimum-bounding-geometry.ht... says that the distance unit is the unit of the feature. The spatial reference of the feature is gcs north american 1983. I read from here (https://gis.stackexchange.com/questions/166525/what-unit-is-the-shape-length-field-in-for-the-gcs-no... that the unit of measurement would be degrees. I was wondering whether you know how I could transform the distance unit from degree to mile. Because you know it's not like from meter to mile where I just multiply it by a scalar. Thank you.

MVP Esteemed Contributor

You should really project your data to get the coordinates in planar values.  That is the reason for you values, they are in units of decimal degrees and those units are not simply "converted" to planar units.

I would run the analysis using a projected coordinate system appropriate for your area.  A conformal projection like UTM, state plane etc would suffice for most purposes

... sort of retired...
New Contributor III

Hello Dan. Thank you for your reply. I projected the map layer onto the state plane projected coordinate system and it worked. Thank you so much.

MVP Esteemed Contributor

... sort of retired...
MVP Esteemed Contributor

Since I was working with some geometry, a small demo

I have helper functions to get what I need from the geometry.  There are other ways to get the data into a numpy array, so not a big deal.  I also have a helper function to calculate interpoint distances.

``````# -- array_poly and npg.eucl_dist my helper functions, nice but not needed
p = array_poly([b0], p_type="POLYGON", sr=None, IFT=None)[0][0]
p.getPart(0)
arr = np.asarray([[i.X, i.Y] for i in p.getPart(0)])
dist = npg.eucl_dist(arr[:-1], arr[1:])
max_idx = np.unravel_index(np.argmax(dist, axis=None), dist.shape)

# --  you can get the x,y pairs
p.getPart(0)  # -- the first part (outer-ring) of the first polygon
<Array [<Point (0.0, 0.0, #, #)>, <Point (2.0, 8.0, #, #)>, <Point (8.0, 10.0, #, #)>, <Point (10.0, 10.0, #, #)>, <Point (10.0, 8.0, #, #)>, <Point (9.0, 1.0, #, #)>, <Point (0.0, 0.0, #, #)>]>

arr   # -- points to array
array([[  0.00,   0.00],
[  2.00,   8.00],
[  8.00,  10.00],
[ 10.00,  10.00],
[ 10.00,   8.00],
[  9.00,   1.00],
[  0.00,   0.00]])

dist  # -- the distance matrix
array([[  8.25,  12.81,  14.14,  12.81,   9.06,   0.00],
[  0.00,   6.32,   8.25,   8.00,   9.90,   8.25],
[  6.32,   0.00,   2.00,   2.83,   9.06,  12.81],
[  8.25,   2.00,   0.00,   2.00,   9.06,  14.14],
[  8.00,   2.83,   2.00,   0.00,   7.07,  12.81],
[  9.90,   9.06,   9.06,   7.07,   0.00,   9.06]])

max_idx
(0, 2)  # row, col

dist[max_idx]
14.142308257222451``````

The results  If you are interested in the helpers let me know.

But this only works for convex polygons.  For concave polygons, you have to parse out the origin-destination pairs that cross the polygon boundary.

... sort of retired...
Tags (3)
by
Esri Regular Contributor

Sorry for my delayed response. It's certainly the best practice to project your data before doing spatial analysis at a relatively local level (vs. global).

In case you want the length calculated in a projected coordinate system (PCS) in the same table, you can use Calculate Geometry Attributes which allows you to specify a PCS for the calculation.

https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-geometry-attribute...