Friday, July 11, 2014

GIS 4102 – GIS Programming Module 7 – Working with Geometries

The assignment for this week's module involved creating a text file with data from a rivers shapefile. This turned out to be a greater challenge than creating a shapefile from a text file. Before committing my scripting results to the text file, I worked out the kinks with just a version printed to the interactive window. After it was printing the proper results, I went back and added the write command. The pseudocode for this assignment is shown below along with a portion of the resultant text file:


Start
Text File Created from a Shapefile
Import modules & classes
Set workspace
OverwriteOutput
Set output path
SearchCursor (OID, SHAPE, NAME)
Open text file
Processing statement
Row Loop
        Set vertex counter
        Point Loop (getPart)
        Increase counter
        Print row
        Write row to text file
Process complete statement
Close text file
Delete row
Delete cursor

End

This scripting turned out to be more challenging than I expected. Something that I found helpful was to comment out certain sections of code while I was making adjustments. That way not only did I preserve code that was working, but I also could alter other code to get the results I needed.

No comments:

Post a Comment