 This video walks through the solution to lesson for practice exercise a Where you have a text file with some coordinates that looks like this And you need to loop through those coordinates parse them out and then create a polygon out of it to create the shape of a US state So this is a very basic list of coordinates. There's no header here. So we're just gonna blast right through it As if it's a CSV file with two columns and no header In order to do this, we're going to use art pie, which we import in line three and The CSV module for Python, which we import in line four In lines eight and nine We set up some variables referencing the files that we're going to work with in the script So we're working with the mystery state shape file that was provided for you The the shape file is in the WGS 84 geographic coordinate system However, there's no shape or polygon within the shape file yet You're gonna add that and Then line nine references the path to the text file containing all those coordinate points In line 10 we do a little bit of work to detect the spatial reference of the mystery state shape file We're gonna use that later when we start creating geometries This pattern of using the describe method and then getting the spatial reference property should be familiar to you from your work in lesson two In line 13 we open up the text file that has the points So the first parameter with the open method is point file path, which we created in line nine and Then the second parameter is our in quotes, which just means we're gonna open in read mode We're just gonna be reading it. We don't need to write anything to it Then in line 14 we pass that file into the CSV reader constructor so that we can create a CSV reader object That will let us iterate through all the rows in the file in an easy fashion Before we start doing that though in line 18. We create an empty arc pie array object We know in this case, we're just gonna be creating one geometry It's going to be one polygon with one array So it's okay to create that array before we start looping And actually we don't want to create it inside the loop because then we would be creating multiple arrays And we just need one of them in this case In line 21 we actually start looping through the rows in the file each row is going to be represented here by a variable variable called Quartz and so in line 24 We create an arc pie point object And when you create a point you need at least the longitude coordinate, which is the x value and latitude, which is the y Now why we while we typically say latitude longitude when talking about coordinates It's important. Remember that latitude is the y value and longitude is the x So when we're creating a point object, we want to make sure that we supply the longitude first then latitude Now going back to our file, you'll see that in the first column or column zero That's the longitude. So we have Quartz Zero in square brackets in our code and then the next piece is the latitude or the y coordinate And so that's the column with the next one. So we use Quartz one in square brackets for the y Once we have that point Once we have that point We can add it into the array And we just keep doing that cycling through the file until we've added point after point Until we've gotten to the end of the file Now in line 30 The loop is exited Which we know because that line is not indented And we're going to take the array that we made and make a polygon object out of it So we use art pie polygon to refer to the polygon class and the things we pass into the constructor in parentheses are The array itself and then the spatial reference for this geometry, which we retrieved back in line 10 So we've got the polygon all set up But we haven't added it to the shape file yet in order to do that We're going to use an insert cursor in this case. We just use a very simple with statement to create the cursor The insert cursor needs a couple of parameters in order to get started It needs the feature class that we're going to modify Which is referenced by the variable shape file Remember we created that back in line eight and then there's this couple of fields That we're going to modify in our case. We're only going to modify the geometry We're not going to modify any attributes So the way that we supply this tuple is it just has one item or token called shape with the at sign And then our line 34 actually inserts the row and it inserts just the polygon geometry nothing else as we describe When this is done, we should be able to go into ArcGIS pro and verify that we indeed have a polygon inside of that shape file Now one little quirky thing to note about this code is in the last line Where I supplied my tuple of values Corresponding to the tuple of fields associated with the cursor When you're supplying just a single value, it's necessary to follow that up with a comma If my cursor was defined with more than one field say two fields Then my values tuple would not need to end in a comma It's only when specifying just a single value that the values tuple needs this trailing comma Now up through ArcGIS desktop 10.6 This was the way to create polygon or polyline geometries At 10.6 it became possible to create these geometries Using a list of coordinate pairs Instead of an array object So here is an alternative approach to Creating our mystery state polygon Down through line 14. Everything is the same Then on line 18 Note that I create an empty a new empty python list rather than a new object of the arc pi array class Then inside the loop instead of creating an object of the point class and adding it to the array I simply use the list append method to add a tuple Representing the current coordinate pair Finally on the last line of the script I go on to plug my list variable into the insert row statement instead of an array variable So that's a little bit simpler approach to creating geometries and you should feel free to use it if you prefer Though either way will work and you'll definitely see the array of points approach if you're looking at pre 10.6 ArcGIS desktop geometry scripts