Select to view content in your preferred language

How do I calculate the average distance between two random points within a polygon?

225
5
Tuesday
Labels (1)
KyraJoiner
Emerging Contributor

Hello!

I am interested in analyzing national borders to give certain nations "compactness" ratings. There are lots of ways to measure compactness of a polygon, but the method I want to use is to calculate the average direct distance between any two random points within the polygon.

I have my national boundary polygon data, and I have converted that to a raster layer with a cell size of 1km x 1km. I plan on converting that raster to point data for this analysis, but since that will take a long time to both generate and load, I want to be sure what I'm going to do with that point data before I generate it.

Since this analysis is on a national level with only a couple hundred polygons, if I have to separate each of the nations out manually and run the analysis separately for each one, I'm willing to do it. That would be a lot of monotonous effort though, so I'd very much prefer to do it all at once.

0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

Can you provide a reference whereby "average distance between two random points within a polygon" is going to give rise to a compactness measure when there other measures which are easy to calculate?

Compactness measure - Wikipedia

 


... sort of retired...
0 Kudos
KyraJoiner
Emerging Contributor

I don't see how that's important, but it's a curiosity project for the game Geoguessr. The details are a bit off-topic for this forum, but distance from point to point within a country are relevant in this context.

0 Kudos
MervynLotter
MVP Regular Contributor

You could (1) create random points in a polygon using the Create Random Points tool. This tool allows you to specify the number of random points and constrain these to certain polygons, like countries.  (2) Use a spatial join to join the random points back to the countries dataset (to get polygon names with each random point)

(3) Then use the Near tool to calculate the distance between all points. Then (4) use Summary Statics to summarize the output from the Near tool for each polygon.

0 Kudos
KyraJoiner
Emerging Contributor

Hello! That's a good idea, but when I ran the Near tool, it only calculates the distance to the nearest point, which makes it completely unrelated to the shape of the polygon. I'm looking to measure the distance from each point to every other point.

I've decided to do this country by country as the number of points I needed to generate all at once was far too large.

0 Kudos
MervynLotter
MVP Regular Contributor

Then try the Generate Origin-Destination Links tool. I suspect it may work as it links up each point to all other points and includes a link distance field, and the ability to separate the dataset into groups (like countries). Do see Generate Origin-Destination Links (Analysis Tools) | ArcGIS Pro documentation. You can use the same layer for input and destination features. 

 

I am not sure how many random points you will have but a dataset of 1600 points will quickly balloon into 2.5 million+ lines (without grouping)

0 Kudos