Posts

Showing posts from June, 2020

GIS 5103 Module 6

Image
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(

GIS 5103 - Module 5

Image
Overview: In this module, a new file geodatabase is created in Python, files from one folder are copied into the gdb, a selection from one file is made using an SQL query format, and the output is used to inform a dictionary. The dictionary ultimately displays all New Mexico cities which are county seats, and their populations. Process:  To begin this module, I had already completed the exercises, which was very helpful. It provided a very clear direction for where to go with the different sections in this module. 1) Input arcpy and set the input and output data paths, and ensure they are able to be overwritten. This includes creating an output to a new file gdb. 2) Define a list of feature classes in the environment, and copy them to the new gdb. 3) Create a search cursor to search within the FEATURE column and select out all rows which contain the value of County Seat. 4) Create a dictionary that defines the key as the city name, and the value as the population, for those ci

GIS 5103 - Module 4

Image
In this module, I was tasked with creating a script in Spyder that will take one existing shapefiles of hospitals, and will perform the following in sequential order: 1) Add XY data, meaning a column for X and a column for Y, and populate them using information in the original point file which lacked XY data. 2) Create a buffer of 1000 meters around the hospitals. 3) Dissolve overlapping buffers into one feature. The script below shows successful completion of these steps in the Spyder console. I had some issues running the script at first. Due to syntax errors, I was struggling to get the XY step to run. I thought the issue was due to corrupted file paths, and spent some time trying to debug in the wrong area. The issue was simple to fix as it was just some extra quotations marks, but it took some looking to catch.  Please see my process summary for more information on my process.  1.       I was getting an error that my file path is not valid, “ExecuteError: Faile

GIS 5103 - Module 2

Image
Introduction and Brief Overview of Module 2 In this module, 4 scripts are written, focusing on while loops and lists. The first script pulls my last name from a string of my name, making my name into a list, and then pulling my last name from the list. The second script runs a dice game in which players 'roll' dice and the outcome is a random name constrained by the number of letters in their first name. The third script runs a list of 20 random numbers between 0 and 10. And the last script identifies if there is an unlucky number in that list, and if so, removes it. My experience with this module and lab Throughout the process of developing and debugging these, I ran into some error messages that largely pointed me in the direction of where in the code my error was, either by highlighting the line with the error and giving a brief statement, or by running the code and getting a more detailed statement in the output as to what word or what error was occurring. This helped

GIS 5103 - Module 3

Image
Debugging:   In this module, three scripts are provided with pre-existing errors. I corrected the errors using Spyder's debugging tools, correcting syntax, and using try-except statements.  Issues and Notes: In this modules, I encountered some errors I had to research a bit to learn how to deal with them and what they mean, I encountered some formatting issues that had to be dealt with before corrected code would work, and I had to use logical thinking to understand first what the process was attempting to do, how it was doing it, and where adjustments or additions were needed to make the code work.  Part 1: Correcting errors In this part, the code is intended to print the field names in a shapefile. The code contains multiple syntax errors. I was able to identify the errors and correct them. The steps are as follows: 1) Look at code, lines with errors will be indicated on the right with note on what the error is. 2) I could catch these errors just by looking at