This practice exercise is designed to give you some experience writing geometries to a shapefile. You have been provided two things:
- A text file MysteryStatePoints.txt containing the coordinates of a state boundary.
- An empty polygon shapefile that uses a geographic coordinate system.
Your job is to write a script that reads the text file and creates a state boundary polygon out of the coordinates. When you successfully complete this exercise, you should be able to preview the shapefile in ArcCatalog and see the state boundary.
If you're up for the challenge of this script, go ahead and start coding. But if you're not sure how to get started, here are some tips:
- In this script there is no header line to read. You are allowed to use the values of 0 and 1 directly in your code to refer to the longitude and latitude, respectively. This should actually make the file easier to process.
- Before you start looping through the coordinates, create an Array object to hold all the points in your polygon.
- Loop through each coordinate and create a Point object from the coordinate pair. Then add the Point object to your Array object.
- Once you're done looping, create an insert cursor on your shapefile. Go to the first row and assign your Array to the SHAPE field.