Week 3 – Weaver

Chapter 3: 

  • Geoprocessing allows you to perform spatial analysis and modeling as well as automate GIS tasks
  • Types of tools in ArcGIS Pro
    • Built-in tools
    • Script tools
    • Model tools
  • Chapter is in depth about geoprocessing tools (already know how to use)
  • Batch processing – execute single tool multiple times using different parameters without further intervention
  • Model builder is can help build a sequence of geoprocessing tools that flow through a visual model
  • Can also use scripting to build model
    • Modelbuilder = visual based
    • Python = text based
  • Scripting has functions that modelbuilder does not have
  • You can schedule python script to run at certain times 
    • Good for routine checks

Chapter 4:

  • Chapter covers fundamentals of Python language
  • Several different data types: strings, numbers, Booleans, lists, tuples, dictionaries
  • Two numerical data types
    • Integers (whole numbers)
    • Floats (fractional numbers)
  • Booleans contain only true and false values
  • // is floor division
  • % is modulus
  • ** is exponents
  • A set of characters surrounded by quotation marks is called a string literal, or string
  • Do not copy and paste code – curly quotation marks will create error
  • Can use str() to put a number into a string 
  • Function is like a little program that is used to carry out an action
    • Ex: int()  str()  print()  type()
  • Method is a function that is couple to an object like a number, string, or list
  • The book is giving us a lot of examples of different things to do with the python and there are so many little nuances
  • == to see if two things have the same value
  • This chapters goes through all the different examples how to use python script – a lot of info, alot to try and take in

Week 2 – Weaver

Chapter 1:

  • Scripting language
    • Automating certain functionality within another program
  • Programing language
    • Development of more sophisticated multifunctional applications
  • Python is scripting language of choice for ArcGIS Pro
  • Used to make redundant tasks/ large amounts processed faster and more efficient
  • The example scripting scared me as I have never coded in my life
  • Python is more basic than C++, easier to work with
  • Python is both a scripting and programming language

Chapter 2:

  • IDE: integrated development environments
  • Scripting is a list of commands that can be run by a program
  • Work with python in so-called command line or command prompt
  • Use the command line that is provided with ArcGIS Pro
    • Want to use arcgispro-py3
  • IDLE: Integrated DeveLopment Environment
    • “Python Shell”
  • So when doing my very first line of code I already got errors…
    • I went and looked at past students and it seems I am not the only one to have run into this problem
    • Since an error came up I did not know how to make the shortcut on the desktop
  • >>> is prompt
  • Different colors are assigned to different parts of the script
  • Writing script vs code different
    • Script menu – file > new file and this opens new untitled window (script window)
  • Spyder: Scientific Python Development Environment
  • Package info outdated (dif buttons)
  • Hard time trying to get Spyder short cut
  • Python scripts = modules 

Nair – Finals

Final: 

  • For the final project, I chose Chapter 5 which is based on Geoprocessing with Python
  • Here, I used the dataset from my 191 Finals and hard-coded the “Clip – Analysis” tool for the Olentangy School District. I clipped all other (four) shapefiles to fit into this district, so only the data from this particular area could be seen 
  • I had no motives for doing so except to see how these data files intersect and if I can actually put into use whatever I’ve learned from the chapter. 
  • Having the dataset from 191 helped as I was just redoing the project in a much more elaborate way without using tools that were developed by some other programmer but by using my own code. 
  • Here are some of my pictures: (Forgot to take them while I actually did this so I had to re-do it, in order to get “proof” that I actually did it): 

  • For the second chapter I chose Chapter 6, I know you said they need to be between 1-4 and 5-8 but I found 5 and 6 the only ones to be actually application based. 
  • Chapter 6 is based on Exploring spatial data so I started by using functions like Exists, and Describe to get started.
  • Exists returns true and false depending on if a dataset exists and describe, describes the data set of a file. A function shapeType can also be used with Describe the shape type of a dataset. 
  • I also played around with List_Fields() and List_Files.

Here are the pictures for that: 

 

I enjoyed taking this class a lot! Overall, I didn’t have much trouble completing tasks except getting the Python Terminal set up. One piece of advice I would have would be for prospective students to take 191 before GIS 193. That class helped me a lot with understanding GIS concepts before I learn how to use Python to implement them.

Nair – Week 6

Chapter 7: 

  • This chapter was mainly about debugging and how to fix errors when coding. 
  • I have done this before my computer science classes, and debugging has become an easier task for me now. 
  • I’ve already been taught a lot of the techniques mentioned in the chapter through my professors so I was able to get through this chapter easily.

Chapter 8: 

  • This chapter was about manipulating spatial and tabular data and using concepts learned in past chapters for application. 
  • I also came across the term cursor – a database technology term for accessing a set of records in a table, and its types( search, insert, update) 
  • These functions are essentially used to insert, update, or search things through tables.
  • The Cursor  also has other functions like delete and reset. 
  • The chapter also talks about working with SQL expressions and text and CSV files. 
  • I’m still learning SQL so it took me a while to understand the syntax
  • It is also interesting to learn that a lot of these tools that we used for GIS 191 and 192 are made using Python. 

Nair – Week 5

Chapter 5: 

  • This chapter introduces ArcPy and geoprocessing using Python
  • I began with setting up my workspace which I had done before for GIS 191 
  • The textbook also mentioned detailed changes to the environment like the env size, XY tolerance, etc. 
  • The chapter mentioned that the key to getting the tool to run right is to get the parameters right. 
    • Usually, they are just: input datasets, tool features, and output datasets 
    • Optional parameters are enclosed in {}   
  • I ran the Clip feature using the syntax instructions given in the textbook.    

Chapter 6: 

  •  This chapter was all about exploring spatial data 
  • This chapter introduced some new functions in ArcPy, and also how to perform batch processing more efficiently. 
  • ArcPy has list functions that include: ListFields(), ListIndexes, ListDatasets(), ListWorkspaces(), and ListVersions()
  • I also noticed that some of the function names had been changed in ArcGIS Pro when compared to the textbook.\
  • The chapter also mentioned some built-in functions for lists that were mentioned in Chapter 4 before like len(returns the length of the list), sort(sorts the list), etc. 

Nair – Week 4

 Chapter 3: 

  • The chapter gets started with geoprocessing and how to use it in parallel with the Python Window. 
  • Getting the Geoprocessing pane to open and understanding how it works was easy for me as I’ve used some of the tools for GIS 191
  • I came across three different types of tools: 
    • Built-in tools: Built with compiled programming languages like C++ For example The Clip Tool 
    • Script Tools: Built using scripting languages like Python. For example Mean Center. 
    • Model Tools: Built using models like Model Builder. For example My Model  
  • The dialog box is also something that I’m well acquainted with due to GIS 191
  • I also used a map from one of the GIS 191 databases to try the “Clip” and “Intersect” tools
  • I also came across the Environment Settings in the Analysis Tab, which can be specified for better efficient usage of the tools. 
  • These environment settings can be coded, or used through individual tools as well \
  • I also came across Batch Processing, which is running the same tools multiple times with different parameters. Dynamic naming of the tool’s output datasets must receive special consideration so that a unique name is used for every iteration of the batch tool. Batch tool outputs are dynamically named using the %Name% variable in output parameters.t
  • Batch mode can also take in multiple raster variables and determine multiple statistics in one go 
  • Then I used the Model Builder. I had used this before for GIS 191. Unfortunately, the dataset I was using did not have variables of different kinds, which posed a problem in connecting the shapes, I believe, But I did not fret about it as I had done this before. 
  • For scripting, I noticed that some of the ways, the code for Clip(Analysis Tool) worked had been changed. 
  • I just had to mention the input layers when I used Clip and the output name, and it gave back the perfect result when I ran the code
  • I also saw the Python Code for “Split By Attribute” in the Analysis Toolbox, which was really cool. 

Chapter 4: 

  • The 4th chapter is about learning how Python works and its syntax 
  • This chapter was a bit easy for me because I’ve done Python before and only had to review some stuff to get started 
  • I also came across Unicode (which helps you print out special characters that might not be in English) which I hadn’t before. 

Nair – Week 3

Chapter 1: 

  • The chapter mentions Python as a “scripting language” more than a programming language. Although I’ve seen this word around a lot in the CS Jargon, I haven’t really understood what it meant. The book mentions a clear distinction between the two. 
  • The chapter also has a structure mentioned, as in a brief of what each chapter in the book entails, and that gives me a clear idea of what I’m going to be doing this semester. 
  • It also mentions the advantages of using Python instead of just relying on the tools offered by ArcGIS Pro. 
  • Was a very laid back introduction to  using Python in ArcGIS Pro, and gave me a gist of what I was getting myself into. 

Chapter 2: 

  • I had trouble as soon as I started. The Python Command Line doesn’t work or show the same things as the textbook. I tried to get the Command Line(Prompt) and IDLE started but wasn’t able to. I got the following error, every time I tried to run: 
  • Traceback (most recent call last):
  •   File “<pyshell#4>”, line 1, in <module>
  •     print(numpy._file_)
  • AttributeError: ‘module’ object has no attribute ‘_file_’
  • >>> 

 

  • I think downloading PyCharm might work? Not sure 
  • I got through it! The Python Window in ArcGIS Pro worked in the end and I did not need to download PyCharm as well. 
  • The Python Window can be accessed by: 
    • (Assuming you have a map opened) → View Tab → Python Pane. (It should show up at the bottom) 
  • The second chapter was an introduction to different types of Python IDEs and environments that can be used to go through with the book. Choosing the Python Window would be better in my opinion since there would be no need for extra downloads. 

 

I got through the first chapter in 20 minutes, however it took some time for the second one. But, I think now that I have figured this out, there should not be much trouble.

McConkey: Course Wrap Up

Python Scripting for ArcGIS Pro

The book is helpful to start to get an understanding of Python, but it is difficult to interpret sometimes as it is prone to using jargon. It does define the jargon, or scripting terms, and explain how the terms relate to each other, but it does get confusing sometimes if you are unfamiliar with a lot of these concepts. The weakest part of the book is that it reads like a walkthrough, but there is no actual data package that comes with it so you are not able to perform all of the scripts it explains. Although the book works as a learning tool, I believe it works better as a reference guide.

Individual Project: ERSI Learning Courses

Even though I was not able to make as much progress as I wanted with the ESRI learning course, I do think the courses make it easier to learn Python much more than the book as you are able to actively learn through working with datasets and writing scripts. Additionally, you are immediately able to see the results of your scripts which makes you feel much more accomplished. There are many learning courses that you should be able to access and many of them are introductory level courses. The directions for the learning courses that I worked through were pretty thorough, so the biggest learning curve comes from navigating PyCharm than writing the code itself.

The work that was completed was certainly worthwhile; however, I hit an error that caused more errors and delays which prohibited me from completing the second learning course I was on.  The main error occurred after I added a python interpreter to PyCharm as instructed in the “Python Scripting for Geoprocessing” course. After the interpreter was added and I ran the completed code and an error code appeared in the console. It reads as follows: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numpy\__init__.py:143: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the-box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service from . import _distributor_init

I tried following the link but that lead to many dead ends. I also discovered that PyCharm stopped recognizing arcpy as a module around this time. This may have been from the version of Python I was using but after I tried changing it, the error still appeared.

I then tried following the file path listed in the error code: “C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\numby\__init__.py:143.” I could not find “__init__.py:143” in the numpy folder.

I went to the settings and clicked on the Python interpreter and saw that the packages are actually listed. I found the mkl-service package in the list so I wasn’t sure why it wasn’t working. I clicked the plus sign to add a package, searched for the mkl-service package, and clicked install. However, an error occurred claiming that I did not “have the write permissions to the target environment.

I worked with someone from OWU tech support and we discovered that I did have administration access and we tried a couple of alternative methods but determined that the error may stem from a problem with the actual PyCharm software itself. Hopefully, you don’t encounter any of these errors as they are a pain to deal with.

Overall, I am proud of the work I was able to complete. I definitely think the learning courses are worth exploring and should maybe be the primary focus of the course, rather than reading the book. I think I retained knowledge better from the courses than from the book itself, but this could be a reflection of my learning style. The book is still a worthy investment. Taking down notes will slow your progress, but they definitely will help you retain more information.

ArcPy Final Assignment

Mack Wade

 

Get Started with Python in ArcGIS Pro

In this course I learned how to write code to determine the number of features for all the feature classes in a workspace. This course also introduced some of the basics of Python syntax as I wrote code into the Python window in ArcGIS Pro.  

In order to begin this project I had to download data from ESRI’s website. I really enjoyed this course and chose to do it because of the downloadable data that I could use as I followed along, unlike the book which did not provide downloadable datasets for it’s walkthroughs. 

The course provided a few shapefiles to work out of, but for this exercise I used the Ambulances.shp. 

First, I ran a tool using Python. In Arc there are many ways and routes to complete one task. This task was to find the count of the items in the shapefile. You can do this in the attribute table or by using the Get Count tool in the Toolbox. You can also find the count by running a script in the Python window. 

To do this you take go to the toolbox history > right click the Get Count tool > Send to Python Window. After sending the window, I manually entered “Ambulances” since that’s the shapefile I want to be working out of. The script looked like this:

arcpy.management.GetCount(“ambulances”)

After completing this task, I learned that when completing a script in the Python window, the history is updated to include the task. 

The next task that I practiced was inputing an assignment statement. 

y = 73 

Then, 

x = 37

Then,

x * y 

Then, after pressing enter, the Python window answered with 2701

Next, I did a similar thing but with Temperature. 

temp_c = 17

temp_f = temp_c * 9 / 5 + 32

print(temp_f)

The Python window responded with 62.6

The next assignment was learning how to use the Python window as a tool to help you when writing code. You can do this by hovering over the prompt and reading the information that the window provides. 

There is also a system of code completion. For example, if you want the “Get Count” tool, you can typer “Get” in the Python Window and suggestions will pop up to help you finish the prompt easier. 

I really enjoyed this tutorial. I thought that it was very easy to follow and was helpful. I see myself using more of ESRI’s resources in the future if or when needed when writing scripts. I think that if any student was interested in this course in the future these tutorials would be a better resource than the book we used.

I had some screen shots from this assignment but they did not get added into the blog format. If you would like me to send those over to you. let me know.