Brief Overview of Module 6
This module involves creating a .txt file in Python, identifying vertices in a .shp file, and transferring selected information from the .shp file into the newly created .txt file.
|
In this flowchart a basic process is summarized for the creation of the script.
1)The input workspace environment is defined, along with the output, and the file that the data will be taken from, which was a shapefile of rivers.
2)A textfile is created next using the open() command, and is set to enable the file to allow writing.
3) A search cursor is created within the rivers shapefile to identify the object ID, the Shape, and the Name.
4) A vertex ID created unique for each vertex within the object next. This is done using a nested for loop, in which actions are performed for each row. First, the vertex ID is defined starting with 1, then the XY data is obtained using the getPart function.
5) This information is then written to the text file using the write() function call. This formats the output to be a row, with the vertex ID, the X,Y input, and the Name.
6) At this point the loop starts over, adding 1 to the vertex ID.
7)The text file is closed and the process is complete.
|
|
Output of script as seen in the txt document. Document is populated with object ID, an original field in the shapfile data set, followed by the uniquely created vertex ID number. The vertex ID number is unique to the vertex that object, and not unique to the vertex within the entire set of 247 vertices. The script then produces the X,Y coordinates for that vertex, and the name of the feature, in this the name of the body of water. |
Comments
Post a Comment