Finding the radius of a circle that circumscribes a polygon

Hello everyone,

I am trying to find the best way of obtaining: the length of the longest line from the center of a polygon to its edge.

In the code below, I download the polygon data of the 75254 zip code located in Texas, USA. I then determine the location of its center with sf::st_centroid() and I plot the geometries using the tmap package.

# Useful packages

library(dplyr)
library(sf)
library(tigris)
library(tmap)

# Download polygon data

geo <- tigris::zctas(cb = TRUE, starts_with = "75254")
geo <- st_as_sf(geo)

# Determine the location of the polygon's center

geo_center <- st_centroid(geo)

# Plot geometries

tm_shape(geo) +
  tm_polygons() +
  tm_shape(geo_center) +
  tm_dots(size = 0.1, col = "red")

Once again, is there an efficient way to determine the length of the line going from the center of the polygon all the way to the farthest point on the polygon's edge? In other words, how can I find the radius of the circle that perfectly circumscribes the polygon given that both the circle and the polygon have the same center? Thank you very much for your help.

1 Like

I'm guessing (too lazy)

 geo$geometry
Geometry set for 1 feature 
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: -96.83016 ymin: 32.93291 xmax: -96.76898 ymax: 32.96036
epsg (SRID):    NA
proj4string:    +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
POLYGON ((-96.82991 32.95374, -96.82227 32.9541...

doesn't the distance from the centroid to the greater of the absolute value of xmax, ymax give the radius?

Theres got to be some room for good old Pythagoras theorem I'd expect :slight_smile:

I think this is what I mentioned in my question. But how do I get the value of that radius?

EDIT: I think I misunderstood you. Yes, you are right actually. I'll do it and post the answer.

EDIT 2: Well, I realize that the radius I am looking for is (in this case) half the distance between xmin and xmax. But still, I am not sure how to obtain it.

1 Like

I'm being lazy again, but convert the bbox to an sf object and use st_distance? At the scale of the object, I don't think you need to go great circle.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.