Using ChatGPT to measure a polygon perimeter
In addition to calculating the area, calculating the perimeter of a polygon is also very useful. We’ll accomplish that in this example, but instead of using a library, we’ll have the powerful artificial intelligence Large Language Model named ChatGPT, which we introduced in Chapter 3, The Geospatial Technology Landscape. We’ll tell ChatGPT in a conversational, precise manner what we want the script to do, which will be calculate the perimeter of a polygon in this case, and then watch it output a script for us!
Before we implement this approach, be aware that ChatGPT will always produce an answer, including incorrect ones sometimes. So you must be careful and test the code it produces. It is also important to be very precise in the prompt you use to generate code to get the result you want. Producing short scripts or functions usually works better than requesting longer ones. It may take you a few tries to get acceptable...