The most difficult part of this lab was saving the final raster. I received an error stating that the raster had no tif attribute. I placed the file extension before the .save function (finalrast.tif.save(S:\GIS_Programming\...)). This returned an invalid pointer error. I then began searching online to look for similar issues and found a thread on stack overflow. Following the advice I found on the thread, I moved the file extension to the end of the file path (...\Results.tif). This allowed me to save the raster; however, it saved in the wrong location. I solved the issue by adding the file name to the file path before the extension (..\Results\FinalRaster.tif).
Showing posts with label GIS Programming. Show all posts
Showing posts with label GIS Programming. Show all posts
Wednesday, June 24, 2020
Module 7: Rasters
The most difficult part of this lab was saving the final raster. I received an error stating that the raster had no tif attribute. I placed the file extension before the .save function (finalrast.tif.save(S:\GIS_Programming\...)). This returned an invalid pointer error. I then began searching online to look for similar issues and found a thread on stack overflow. Following the advice I found on the thread, I moved the file extension to the end of the file path (...\Results.tif). This allowed me to save the raster; however, it saved in the wrong location. I solved the issue by adding the file name to the file path before the extension (..\Results\FinalRaster.tif).
Wednesday, June 17, 2020
Module 5: Exploring & Manipulating Data
While printing the results of the search cursor, I kept receiving
an error from the POP_2000 field. The value of the field is an integer and the
code I was using required a string. I tried putting the code in quotes, but that just returned the code and not the value desired. I took a brief break and realized that I needed to turn the value into a string by placing the code within the str() function. This fix was a simple one, yet it was the only part of the lab that I struggled with.
Wednesday, June 10, 2020
Module 4: Geoprocessing
I began by writing the code to import the arcpy and env modules. I then wrote the code for setting the workspace and adding the XY coordinates. I manually wrote the code for printing the task being conducted and utilized the GetMessages function for the rest of the messages printed. At this point, I realized I had not included a means for overwriting outputs and went back to insert code for this after the workspace setting. The code for creating the buffer came next, along with the manual code for printing the task and the GetMessages function for the rest of the printed messages. I included \n in the print code to make the printed messages easier to read. Finally, I wrote the code for dissolving the buffer into its own layer and for printing the messages. The code for these messages was written in the same manner as the previous messages, also with the inclusion of the \n. All code in the script used the syntax for a stand-alone script. The flowchart for this script is depicted in the above (bottom) screenshot.
Wednesday, May 27, 2020
Module 2: Python Fundamentals
This week's lesson focused on the fundamentals of Python. The lab required us to write code that printed our last name from a list, compiled a list of random integers between 0 and 10, and removed a designated integer from that list. We were also required to debug a selection of code for a dice game. In the process of completing the assignment, we were required to utilize while loops and several methods. Among these methods were the append, remove, and count methods.
For the removal of the designated integer, first I assigned the integer to be removed to the variable "unlucky". I then wrote the code for finding, counting, and printing the number of "unlucky" integers in the "luckyList" list before I ran the code to test it and copy/pasted it into the script. The code for the removal of all "unlucky" integers from the list was written and then ran to test it before it too was copy/pasted into the script. Finally, I wrote the code for printing luckyList and ran the script to ensure the whole code worked together. The results of the script (top) and the flowchart for the creation and updating of luckyList (bottom) are pictured above.
Monday, May 18, 2020
Module 1: Introducing Python
This week's lab had us open a code file in Spyder and run the code to create the data folder file paths we will need for the rest of the semester in GIS Programming. The resulting data folders for each module are shown in the screenshot above. The process of opening the code file and running the code was rather simple and intuitive. The most confusing part of the assignment was the code itself. Fortunately, this was provided to us and will surely make more sense as the semester progresses. I look forward to the rest of this class and understanding how this code works.
Subscribe to:
Posts (Atom)



