Tuesday, July 17, 2018

GIS Programming Module 8

This week in the lab we practiced pulling data from shapefiles and writing it in .txt files on Notepad for example. The process also works in reverse where you can pull information from a .txt document and populate shapefile attribute data. The results are shown below. The goal was to pull attribute data out of a shapefile and print it into a .txt file in a configuration that was readable.
The following pseudocode was used to accomplish the process. I am not including the actual code for obvious reasons, but this should show the overarching thought process behind populating a .txt file from attribute data.
START
Modules and Classes imported
Workspace set
Overwrite settings changed to overwrite existing files
Working shapefile variable set
Search Cursor used to select FID, Shape, and NAME attributes
Text document created for data to be written in
Iteration through rows started
    Vertex variable created, set to 0
    Iteration through arrays and points started
          Vertex variable changed to add 1
          Variable created as a string of text to write to file
                Result printed in Interactive window to error check
                Data written to .txt file
Text file closed
Variables row and cursor are deleted
END

No comments:

Post a Comment