How Circular is a Circle? How Square is a Square?
- 3 days ago
- 5 min read
![Fig. 1. Johnson Earthworks [Author Image]](https://static.wixstatic.com/media/eaded0_c3eb7d42aec54e7794b2c83146431a16~mv2.png/v1/fill/w_438,h_252,al_c,q_85,enc_avif,quality_auto/eaded0_c3eb7d42aec54e7794b2c83146431a16~mv2.png)
The footprints of human-made structures consist mainly of straight lines and curved lines. When these lines enclose space, they are called polygons. Two important enclosed spaces are the circle and the square. A square has four equal sides, while a circle can be said to have either one side or infinite sides. Remote imagery, such as LIDAR, has been important for archaeology in that it has expanded the abilities of what we can see, finding traces of past cultures. Structures built using circles and squares, because of their uniqueness and mathematical relationships, may have special meanings to the culture that built them. The ability of a culture to construct a structure in the form of a perfect circle, a rectangle, or a square says much about both the technology involved and the intent. I introduce here two scripts, written in Python, for the open-source program QGIS, that measure the circularity of a circular object and the squarishness of a square one.
I want to talk about how I wrote these scripts. I used Google's Gemini AI to assist me. [Google 2026] There are several reasons for this. I have 11 years of experience writing code for ESRI GIS. I am new to QGIS coding, and I'm unfamiliar with the naming conventions and structures. That said, GIS coding is not difficult algorithmically, mainly because the code conforms to a directional bigraph. The main reason I wanted to try this is that I'm a slow, terrible typist. My fingers don't work for touch typing. I remember middle school typing class using these ancient typewriters. It was agony. I've had this disability all my life. I have many issues with AI, the way it is being imposed upon us in an increasingly authoritarian manner, the reckless building of data centers, the idea that people's jobs are just garbage that can be easily replaced, and the unending hype. I have heard that Gemini is a good model and that the one thing AI can do well is write code, so I decided to try it out. If something works and is useful, then use it.
![Circular Bisector [bunglesmate 2008]](https://static.wixstatic.com/media/eaded0_457d517c456643008283f83aa20b55a9~mv2.png/v1/fill/w_578,h_576,al_c,q_85,enc_avif,quality_auto/eaded0_457d517c456643008283f83aa20b55a9~mv2.png)
The Perpendicular Bisector Theorem states that for any two points on a circle, a line perpendicular to the chord and going through the center point of the chord will go through the center of the circle. This means that multiple chords will intersect at this center point. Any deviation in the shape of the circle will create a cloud of points near the center point, and the average center point will be the centroid of that cloud. There is also a problem that this is the geometry of a continuous surface, and it must be mapped onto a discrete surface, an array of tiny squares called pixels. This means that the mapping will be imperfect. The error, however, must fall within some boundary. It must be less than the resolution of the DEM, which for me is 1.25 feet.
In QGIS, I created a center point and then a polygon circle using that point as the center. The radius is 646.076 feet, larger than the geometric earthwork circles in Ohio. I created an outline of the circle and then distributed 12 points evenly around it. With these points selected, the script will calculate a center.
I explained to Gemini what I wanted, pasted in the code, and ran the script. I was pleasantly surprised that there were no syntax errors. There were bugs. The point cloud formed three concentric rings around the center, and the centroid is over 10 feet from the center. Not good enough!
I next created the lowest point set on the circle where these outliers appear. This turned out to be 4 points. With 4 points, two of the candidate centers are outliers. Next, I numbered the points to find out which pairs of chords were outliers. This happens when the chords are parallel. So I filtered this out and ran it again with 12 points. This gave me a distance from the true center of .001 foot, well within my criteria. However, looking at my point cloud, there still could be room for improvement:
![Fig 2. Candidate Point Cloud. Centroid in red. True center in blue [Author image]](https://static.wixstatic.com/media/eaded0_07d558dafdbe4e32bfcd891764dbe891~mv2.png/v1/fill/w_439,h_593,al_c,q_85,enc_avif,quality_auto/eaded0_07d558dafdbe4e32bfcd891764dbe891~mv2.png)
Notice that three 'lines' of points skew the centroid to the right. These outliers might need to be looked into at some time. The standard deviation of the point cloud from the center is .018 foot. The new diameter is 646.0371 feet. Also, remember that when I created the circle, the snap radius was set to the default 13 pixels, another slight source of error.
One more question to answer. Does a smaller circle make the program less accurate? To test this, I created a circle of 48.751 feet radius with 12 points. The result is 1.254e-04 feet from the actual center, with a point cloud standard deviation of .003 feet, and the new radius is 48.7474 feet. Thus, the smaller circle is more accurate, but the point cloud is slightly rougher than the large circle. So the script works within my criteria for both sizes.
To analyse a square is straightforward. Here is the basic statement I gave Gemini:
Write a QGIS 3.x Python program to find squarishness. Given a selected point feature containing four points with “id” numbers 1 to 4. Ids 1,2 2,3 3,4 4,1 form the outside lines. Ids 1,3 and 2,4 form the diagonals. Find the centroid, and put it in a point feature. Add the standard deviation of the interior angles, the standard deviation of the edge length, the standard deviation of the vertices’ distance to the centroid, and the difference between the diagonals' length normalized by the total edge length.It is important to specify the version of QGIS you are using because the Python code changes for different versions. I have added more attributes, like the lengths of each side, and given them alias names.
A squircle is a type of superellipse, also called a Lamé curve. A family of parameterized curves, the formula given below:
![Formula for a superellipse [Wikipedia 2026b]](https://static.wixstatic.com/media/eaded0_0817c32beef9463680240c920c6583be~mv2.png/v1/fill/w_434,h_148,al_c,q_85,enc_avif,quality_auto/eaded0_0817c32beef9463680240c920c6583be~mv2.png)
To get a squircle, n = 4, and a=b=r, the formula becomes:
x⁴ + y⁴ = r⁴ [Kumar 2023]
![Graph of a squircle where r = 1 [Wikipedia 2026a]](https://static.wixstatic.com/media/eaded0_bba452fcf9a2482f88b18b8d10906f0d~mv2.png/v1/fill/w_500,h_500,al_c,q_85,enc_avif,quality_auto/eaded0_bba452fcf9a2482f88b18b8d10906f0d~mv2.png)
Since this is a complex mathematical structure, it was seldom used in design until the advent of computer graphics. Apple is famous for using it in the shape of computer keys and for iconography. [Silvestrovic 2026] So why does this form show up in the shape of small earthworks over 2 thousand years old? [Davis & Burks 2020, p. 20] Is there a manual way to form a squircle? I haven't found much. One interesting way is by squeezing the four sides of a flexible tube. [Barry 2016] These indigenous structures are said to look like squircles, but really, how accurate is that statement? There is an analytical solution to the area of a squircle, but I have found none for the perimeter. An estimate can be made, however, in GIS. I have not yet created any code for this purpose.
The geometric earthworks in eastern North America during the Middle Woodland period reflect a deep mathematical language built into a landscape. This is from a culture that had no written language. To parse out this mathematical language, tools must be constructed to understand just what is being said.
Code:
Barry, Nathan. 2016. “Make Your Own Squircle.” https://geekdad.com/2016/07/squircle/.
bunglesmate. 2008. “How to Find the Center of a Circle.” Instructables. https://www.instructables.com/How-to-find-the-center-of-a-circle/.
Davis, Jamie, and Jarrod Burks. 2020. “Vol. 1 Ch. 1 Indiana Earthwork Sites New Insights from LiDAR DEMs and Aerial Photographs.” In Encountering Hopewell in the Twenty-First Century, Ohio and Beyond, vol. 1. University of Akron.
Google. 2026. Gemini (2.0 Flash version) [Large multimodal model]. https://gemini.google.com/app
Kumar, Anmol. 2023. “Making Squircles in After Effects.” Medium, July 26. https://medium.com/@anmol_k/making-squircles-in-after-effects-f69b41f4baf1.
Silvestrovic, Antoni. 2026. “How Apple Uses Squircles in iOS Design.” 2026. https://squircle.js.org/blog/squircles-in-apple-design.
Wikipedia. 2026a. “Squircle.” In Wikipedia. 2026. https://en.wikipedia.org/w/index.php?title=Squircle&oldid=1356713550.
Wikipedia. 2026b. “Superellipse.” In Wikipedia. 2026. https://en.wikipedia.org/w/index.php?title=Superellipse&oldid=1355974827.



Comments