├── .gitignore
├── .idea
├── .gitignore
├── inspectionProfiles
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── programming-for-gis-and-rs.iml
└── vcs.xml
├── Final Project
├── Example 1 - STL Crime.pptx
├── Example 2.pptx
├── Example 3 - Image Processing.pptx
├── Example 4 - GIS 5090-Final Project.pptx
├── Example 5 - Lockmiler_finalprojectProposal.pptx
├── Example 6- Snap Point to Line Feature Geoprocessing Tool - Proposal.pptx
├── Proposal.md
└── README.md
├── GIS 4090-5090 Programming for GIS&RS Syllabus Fall 2020.docx
├── ILoveToCode.md
├── InstructorInformation.md
├── LearnToCode.md
├── LectureLiveStream.md
├── LetsRoll.png
├── Project 1
└── README.md
├── Project 2
└── README.md
├── README.md
├── Unit 1
├── Lecture_1_Slides.pptx
├── Missouri.gdb.zip
├── README.md
├── Welcome.pptx
├── configuring_the_notebook_directory.html
├── unit_1_lesson_1_intro_to_python.ipynb
└── unit_1_lesson_2_more_python.ipynb
├── Unit 10
├── README.md
└── addresses.csv
├── Unit 11
├── README.md
├── STL_Crime_1.gdb.zip
├── STL_Crime_gjb.gdb.zip
├── Thunder_Acquisitions_gjb.csv
├── Thunder_Departures_gjb.csv
├── national_rainfall_data_demogjb.zip
└── nbrhds_wards_demo1.zip
├── Unit 12
├── Lecture 1 - Matplotlib.ipynb
├── Lecture 2 - Intro to Spatial Dataframes (Feature to CSV in Lat and Longitude).ipynb
├── Lecture 3 - CSV to Spatial DataFrame to GIS Data.ipynb
├── Lecture 4 - plotting_with_plotly.ipynb
├── README.md
├── SENZA_0_SUNAA_0_CORN.xlsx
├── crime_data.gdb.zip
└── matplotlib_styles.ipynb
├── Unit 13
└── README.md
├── Unit 14
└── README.md
├── Unit 15
└── README.md
├── Unit 2
├── README.md
├── blocks_files.png
├── unit_1_lesson_2_more_python.ipynb
├── unit_2_lesson_1_geoprocessing_in_arcgis_pro.ipynb
├── unit_2_lesson_1_geoprocessing_in_arcmap.ipynb
├── unit_2_lesson_2_arcpy_in_arcgis_notebooks.ipynb
└── unit_2_lesson_2_arcpy_in_arcgis_pro.ipynb
├── Unit 3
├── OSM.zip
├── README.md
├── Singapore_Data.gdb.zip
├── data.zip
├── describe_demo_data.zip
├── unit_3_lesson_1_exploring_spatial_data.ipynb
├── unit_3_lesson_2_environments_and_coordinates_systems.ipynb
└── unit_3_lesson_3_text_files_and_csvs.ipynb
├── Unit 4
├── Crime.gdb.zip
├── Cursor_Lecture_Slides.pptx
├── Exercise07.zip
├── README.md
├── insert_cursor_crime.py
├── search_cursor_crime.py
├── unit_4_lesson_1_cursor_demos.ipynb
└── update_cursor_crime.py
├── Unit 5
├── README.md
├── unit_5_lesson_1_geometries.ipynb
└── week_5_slides.pptx
├── Unit 6
├── Exercise09.zip
├── README.md
├── Unit_6_Rasters.pptx
├── unit_6_lesson_1_working_with_rasters_arcpy.ipynb
├── unit_6_lesson_2_working_with_rasters_numpy.ipynb
├── unit_6_lesson_3_working_with_rasters_in_the_cloud.ipynb
├── working_with_rasters_arcpy__xid-18874256_1.html
├── working_with_rasters_in_the_cloud__xid-18874257_1.html
└── working_with_rasters_numpy__xid-18874258_1.html
├── Unit 7
├── Python_GP_Tools.ppt
├── README.md
├── problem1_script.py
├── problem2_script.py
├── unit_7_boto_and_azure.ipynb
└── unit_7_gdal__xid.ipynb
├── Unit 8
├── February2020.CSV
├── README.md
├── functions_example.html
├── functions_example.ipynb
├── requests.html
├── requests.ipynb
├── try_except.html
└── try_except.ipynb
├── Unit 9
├── Oklahoma_City_Thunder.png
├── README.md
├── all_week_aug_13_20.csv
├── chennai-rainfall.csv
├── me.gif
└── profile_pic.jpg
├── Welcome.md
├── utilities
└── final_project_order.py
└── ~$S 4090-5090 Programming for GIS&RS Syllabus Fall 2020.docx
/.gitignore:
--------------------------------------------------------------------------------
1 | *username*
2 | sample_docs/*
3 | *answer*
4 | code_arcpy_and_arcgis/*
5 | Week_10/lecture_imagery/*
6 | Week_10/Landsat_p114r75/*
7 | Week_10/Amberg_tif/*
8 | Week_9/Exercise09/*
9 | Week_9/python_exercises_all_chapters*
10 | *Homework*
11 | Project_2_Ideas/*
12 | Week_11/Exercise10/Exercise10/Austin/
13 | Week_11/Exercise10/Exercise10/
14 | Week_12/Project*
15 | Unit 3/dems.zip
16 | Unit 3/csv_demo_data.zip
17 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Default ignored files
3 | /workspace.xml
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/programming-for-gis-and-rs.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Final Project/Example 1 - STL Crime.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Final Project/Example 1 - STL Crime.pptx
--------------------------------------------------------------------------------
/Final Project/Example 2.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Final Project/Example 2.pptx
--------------------------------------------------------------------------------
/Final Project/Example 3 - Image Processing.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Final Project/Example 3 - Image Processing.pptx
--------------------------------------------------------------------------------
/Final Project/Example 4 - GIS 5090-Final Project.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Final Project/Example 4 - GIS 5090-Final Project.pptx
--------------------------------------------------------------------------------
/Final Project/Example 5 - Lockmiler_finalprojectProposal.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Final Project/Example 5 - Lockmiler_finalprojectProposal.pptx
--------------------------------------------------------------------------------
/Final Project/Example 6- Snap Point to Line Feature Geoprocessing Tool - Proposal.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Final Project/Example 6- Snap Point to Line Feature Geoprocessing Tool - Proposal.pptx
--------------------------------------------------------------------------------
/Final Project/Proposal.md:
--------------------------------------------------------------------------------
1 | # Final Project Proposal
2 | In my experience, all students and professionals need at least one demo or
3 | presentation that they can be prepared to give for a job interview,
4 | conference presentation, or other type of meeting. Through this class,
5 | I’d like each student to develop that demo or presentation, with the
6 | foundation of that presentation being some sort of spatial analysis,
7 | imagery analysis, or GIS analysis with Python. Each student will be
8 | responsible for a short 5-10 minute presentation to be given during
9 | the final week of class on a project of their own choosing that will
10 | leverage Python. In this discussion forum, please submit a short write
11 | up (no more than 5 bullet points) of what your project will be,
12 | what problem you will solve, how you will use Python to solve the
13 | problem. Also, please read and comment on at least 2 proposals
14 | from your classmates.
15 |
16 | On December 2, please be prepared to give a 5-10 minute presentation
17 | to the class via Zoom explaining your problem, solution, how you got
18 | there, and hopefully some cool maps and results.
19 |
20 | This is the first time I have used discussion forums in Blackboard,
21 | so please let me know if this isn't working as expected. **Start a
22 | "New Thread" and enter your proposal!**
23 |
24 | For examples of what students have proposed in the past, see the
25 | Power Point slides in the **Final Project Proposal** folder.
26 |
27 | **Due date for proposal submission is midnight, October 16.**
28 |
--------------------------------------------------------------------------------
/Final Project/README.md:
--------------------------------------------------------------------------------
1 | Please submit your final project here.
2 |
3 | For your final projects, you are expected to give a 5-10 minutes presentation
4 | on Week 15 (5/6) of class. I will be including the presentation as part of the
5 | final project grade.
6 |
7 | Your final project submission should include your presentation, code,
8 | and any data products you produce. Please submit this all in a single
9 | zipped folder.
10 |
11 | I have used Python to randomly assign an order to the presentations.
12 | Below is the order we will go through presentations:
--------------------------------------------------------------------------------
/GIS 4090-5090 Programming for GIS&RS Syllabus Fall 2020.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/GIS 4090-5090 Programming for GIS&RS Syllabus Fall 2020.docx
--------------------------------------------------------------------------------
/ILoveToCode.md:
--------------------------------------------------------------------------------
1 | **Basketball** – https://github.com/gbrunner/court-js
2 |
3 | **Fun maps!** – https://twitter.com/gregbrunn/status/718271695212126213
4 |
5 | **Notebooks** - http://earthpy.org/analyzing-whale-tracks.html
6 |
7 | **Baseball** - https://gavinr.com/2016/12/22/create-pitch-charts-python/
8 |
--------------------------------------------------------------------------------
/InstructorInformation.md:
--------------------------------------------------------------------------------
1 | # Instructor Information
2 |
3 | **Instructor Name**: Gregory Brunner
4 |
5 | **Contact Information**: gregory.brunner@slu.edu
6 |
7 | **Virtual Office Hours**: 4 - 5 PM on Monday via Zoom - https://slu.zoom.us/j/98618329215?pwd=QmtPK3RrUnVybzlhZDcwdFVWdXpiQT09
8 |
9 | **Brief Biography**: Mr. Brunner is an experienced scientist and
10 | awards winning professor. He is an expert in the fields of
11 | geographic information systems (GIS), geospatial application development,
12 | remote sensing, big data analytics, Python, and ArcGIS.
13 | He is an excellent teacher who has taught undergraduate and
14 | graduate level geospatial programming courses at Saint Louis University.
15 | He has served on multiple academic program boards. He is an intelligent
16 | and passionate research professional with a Master of Science (MS) in
17 | Physics from Rice University. He has given presentations across the
18 | world on topics ranging from green infrastructure to augmented reality.
19 |
--------------------------------------------------------------------------------
/LearnToCode.md:
--------------------------------------------------------------------------------
1 | Watch this awesome introduction to Python - https://www.youtube.com/watch?v=rkx5_MRAV3A
--------------------------------------------------------------------------------
/LectureLiveStream.md:
--------------------------------------------------------------------------------
1 | Gregory Brunner is inviting you to a scheduled Zoom meeting.
2 |
3 | Topic: Weekly Lecture
4 | Time: Aug 19, 2020 04:00 PM Central Time (US and Canada)
5 | Every week on Wed, 15 occurrence(s)
6 | Aug 19, 2020 04:00 PM
7 | Aug 26, 2020 04:00 PM
8 | Sep 2, 2020 04:00 PM
9 | Sep 9, 2020 04:00 PM
10 | Sep 16, 2020 04:00 PM
11 | Sep 23, 2020 04:00 PM
12 | Sep 30, 2020 04:00 PM
13 | Oct 7, 2020 04:00 PM
14 | Oct 14, 2020 04:00 PM
15 | Oct 21, 2020 04:00 PM
16 | Oct 28, 2020 04:00 PM
17 | Nov 4, 2020 04:00 PM
18 | Nov 11, 2020 04:00 PM
19 | Nov 18, 2020 04:00 PM
20 | Nov 25, 2020 04:00 PM
21 | Please download and import the following iCalendar (.ics) files to your calendar system.
22 | Weekly: https://slu.zoom.us/meeting/tJcufuCpqDsuHNRkwv1LpuazXGXg4Gw5DHoQ/ics?icsToken=98tyKuCrrTIjG9KVtB-HRowqA4r4XevwpmJbgo1vlwjzUgxDdwLsDsV6NeZYB430
23 |
24 | Join Zoom Meeting
25 | https://slu.zoom.us/j/93399160460?pwd=azZrQXNlWG5ZUW44TktZYlVWdHlaUT09
26 |
27 | Meeting ID: 933 9916 0460
28 | Password: 408750
29 |
30 | One tap mobile
31 | +13126266799,93399160460# US (Chicago)
32 | +19292056099,93399160460# US (New York)
33 |
34 | Dial by your location
35 | +1 312 626 6799 US (Chicago)
36 | +1 929 205 6099 US (New York)
37 | +1 301 715 8592 US (Germantown)
38 | +1 346 248 7799 US (Houston)
39 | +1 669 900 6833 US (San Jose)
40 | +1 253 215 8782 US (Tacoma)
41 | Meeting ID: 933 9916 0460
42 | Find your local number: https://slu.zoom.us/u/aHo8GueHA
--------------------------------------------------------------------------------
/LetsRoll.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/LetsRoll.png
--------------------------------------------------------------------------------
/Project 1/README.md:
--------------------------------------------------------------------------------
1 | # Spring 2020
2 | ## Problem 1 (15 Points)¶
3 |
4 | Unzip imagery.zip. Create a Notebook that uses arcpy Answer the following questions:
5 |
6 | 1. How many rasters are in the folder?
7 | 2. What is the projection of the rasters?
8 | 3. Do all the rasters have the same projection?
9 | 4. How many bands to the rasters have?
10 | 5. What is the raster format?
11 |
12 | Please use markdown cells to explain your answers. I'm not looking for anything too fancy here, just show me how you can use Python and arcpy to answer these questions.
13 |
14 | ## Problem 2 (15 Points)
15 |
16 | Unzip tlgdb_2019_a_us_school.gdb. Create a Notebook that uses arcpy to create a report about the features in the geodatabase. List out the following:
17 |
18 | 1. Feature class name
19 | 2. Number of features in the feature class
20 | 3. Projection of the feature class
21 | 4. Shape type of the feature class (point, polyline, polygon, etc.)
22 |
23 | Bonus (5 points) Write your results out to a text file or comma separated text file.
24 |
25 | ## Problem 3 (15 Points)
26 |
27 | Unzip usa_cities.gdb.zip. Identify the largest cities in the United States that have a population greater than 1 million people. Using Python, print a table that lists those largest cities and their corresponding population, according to the cities feature class. Use **POPULATION** as the population field.
28 |
29 | I recommend using ```arcpy.da.SearchCursor``` to iterate through the cities feature class to create a list of the cities and corresponding populations.
30 |
31 | ## Problem 4 (15 Points)
32 |
33 | Unzip usa_cities.gdb.zip. Create a list of city capitals and their corresponding state.
34 |
35 | I recommend Using ```arcpy.da.SearchCursor``` to iterate through the cities feature class to create a list of the cities and corresponding populations.
36 |
37 | ## Problem 5 (20 Points)
38 |
39 | Create a Python script or Notebook that copies all cities with a population over 1 million to a new feature class in the same geodatabase.
40 |
41 | I recommend exploring the following GP tools:
42 |
43 | - [Make Feature Layer](https://pro.arcgis.com/en/pro-app/tool-reference/data-management/make-feature-layer.htm)
44 | - [Select Layer by Attribute](https://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-layer-by-attribute.htm)
45 | - [Copy Features](https://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm)
46 |
47 | ### Bonus (10 points) Using a for loop, write out the following 4 feature classes:
48 |
49 | 1. Feature class with a population greater than 1 million.
50 | 2. Feature class with a population between 500,000 and 1 million.
51 | 3. Feature class with a population between 100,000 and 500,000.
52 | 4. Feature class with a population less than 100,000
53 |
54 | ## Grading
55 |
56 | The project is out of a total of 100 points, 80 points for the problems, 20 points for you code documentation. Please use Markdown cells in your notebooks to explain what you are doing or code comments such as ## in your code cells. Any Bonus points can your score above 100 percent.
--------------------------------------------------------------------------------
/Project 2/README.md:
--------------------------------------------------------------------------------
1 | # Spring 2019
2 | Please Complete Both Problems
3 |
4 | ## Problem 1 (**60 Points**)
5 | There is a tool in ArcGIS Pro and ArcMap called [Points to Line](https://pro.arcgis.com/en/pro-app/tool-reference/data-management/points-to-line.htm). This tool creates line features from points. **For this problem, do not use that tool!**. What I want you to do is essentially create that tool using cursors.
6 |
7 | What I would like you to do is create a line feature from the point features in **zoo_featues_wgs84.shp** by using a search cursor to retrieve the x,y locations of the points and an insert cursor to insert thost features into a new feature class.
8 |
9 | Grading this problem breaks down as follows:
10 | - Read geometries from **zoo_features_wgs84.shp** (10 points)
11 | - Create a new *'Polyline'* features class (10 points)
12 | - Convert points to a line (10 points)
13 | - Insert points into *'Polyline'* feature class (10 points)
14 | - Create Python Script Tool to turn points into a polyline
15 | - User interface (10 points)
16 | - Connecting the script to the tool with right parameters (10 points)
17 |
18 | If you a re looking for a starting point, I recoment looking at Zandbergen's Chapter 8 Challenge Problems and Solutions.
19 |
20 | ## Problem 2 (**40 points**)
21 | Write a Python script that uses *Raster* objects (see Zandbergen Chapter 9) and Spatial Analyst to create an average (mean) raster from p114r075_7t20000501_z50_nn10.tif, p114r075_7t20000501_z50_nn20.tif, p114r075_7t20000501_z50_nn30.tif, and p114r075_7t20000501_z50_nn40.tif found here (). Use mathematical operations similar to achieve this. If you need help, look to the exercises from Chapter 9 of Zandbergen.
22 |
23 | # Fall 2020
24 | ## Problem 1 (out of 50 points)
25 | Here is a list of Landsat Scenes over Oregon:
26 |
27 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B1.TIF
28 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B2.TIF
29 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B3.TIF
30 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B4.TIF
31 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B5.TIF
32 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B6.TIF
33 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B7.TIF
34 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B8.TIF
35 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B9.TIF
36 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B10.TIF
37 | https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/LC08_L1TP_046028_20200908_20200918_01_T1_B11.TIF
38 |
39 | You can also access them through: https://landsat-pds.s3.amazonaws.com/c1/L8/046/028/LC08_L1TP_046028_20200908_20200918_01_T1/index.html
40 |
41 | Using Python, create the following raster products:
42 |
43 | 1. [Calculate the NDVI of the scene (10 points)](https://www.usgs.gov/core-science-systems/nli/landsat/landsat-normalized-difference-vegetation-index?qt-science_support_page_related_con=0#qt-science_support_page_related_con)
44 | 2. [Calculate the SAVI of the scene (10 points)](https://www.usgs.gov/core-science-systems/nli/landsat/landsat-soil-adjusted-vegetation-index#:~:text=This%20image%20displays%20a%20(left,Adjusted%20Vegetation%20Index%20(SAVI).&text=SAVI%20is%20used%20to%20correct,where%20vegetative%20cover%20is%20low.)
45 | 3. Using [Composite Bands](https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/composite-bands.htm), create a 3 band R-G-B image from [bands 2, 3, and 4 (10 points)](https://gisgeography.com/landsat-8-bands-combinations/)
46 | 4. Using [Composite Bands](https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/composite-bands.htm), create a false color infrared image from [bands 3, 4, 5 (10 points)](https://gisgeography.com/landsat-8-bands-combinations/)
47 |
48 | Be sure to save the resulting rasters to disk as TIF files.
49 | Please create a clear, well-documented script or notebook.
50 | The readability will be graded out of 10 points.
51 |
52 | You can use ```arcpy``` or ```numpy```. Just solve the problem.
53 |
54 | ## Problem 2 - Out of 50 Points
55 |
56 | Turn script2.py into an ArcGIS Python GP Tool.
57 | Please submit the modified python script and the ArcGIS geoprocessing toolbox.
58 | You can test the script with the August2020.CSV file that is attached.
59 |
60 | I am being very open ended here.
61 | I just want to see you complete the tasks.
62 | Don't over think it.
63 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Course Description
2 | This course will introduce students to Python programming and its
3 | applications to remote sensing and GIS. Through completing this course,
4 | students will be able to use Python to perform common GIS and remote
5 | sensing analysis tasks, automate workflows, and develop custom Python
6 | tools. Topics will include describing data, manipulating data,
7 | automating spatial analysis tasks, creating Python scripts and tools,
8 | and using Python for imagery analysis. We will also introduce students to
9 | WebGIS and how Python can be used to interface with data that is shared online.
10 |
11 | # Course Objectives
12 | - Students will learn Python and understand how to use it to
13 | solve problems in GIS and Remote Sensing and will demonstrate
14 | their knowledge by completing multiple homework assignments and projects.
15 | - Students will be encouraged to use Python through relevant
16 | examples and assignments.
17 | - Students will begin implementing it in their own research
18 | projects such as theses and capstones.
19 |
20 | # Materials
21 | Course Materials will be shared using Blackboard. Slides, labs,
22 | and homework are in the folders that correspond to the specific units covered in class.
23 |
24 | # Texts
25 | - (Primary Textbook) Paul A Zandenbergen. [Python Scripting for ArcGIS Pro.](https://esripress.esri.com/display/index.cfm?fuseaction=display&websiteID=393&moduleID=0) ISBN: 9781589484993. $79.99
26 | - Paul A Zandenbergen. [Advanced Python Scripting for ArcGIS Pro.](https://esripress.esri.com/display/index.cfm?fuseaction=display&websiteID=384&moduleID=12) ISBN: 9781589486188. $79.99
27 | - (Optional) Laura Tateosian. Python for ArcGIS. ISBN 978-3-319-18398-5. $99.00
28 |
29 | # Grading
30 | 1. 15% - Lab Work & Programming Exercises
31 | 2. 15% - Homework Assignments
32 | 3. 20% - Project 1
33 | 4. 20% - Project 2
34 | 5. 30% - Final Project
35 |
36 | # Feedback and Assessment
37 | In order to ensure that students are on track to achieve the course objectives,
38 | students will have weekly coding assignments. The coding
39 | assignments will be graded and returned before the next online
40 | lecture, where the solutions will be reviewed, and questions will
41 | be addressed. Feedback on respective assignments will also be given to
42 | each student through Blackboard. Weekly assignment will become the
43 | foundation for student projects which will serve as the benchmarks for
44 | whether students understand how to use programming to solve GIS and
45 | remote sensing problems. There will be 3 projects over the course of
46 | the semester. Two will be defined by the professor. The third and final
47 | project will be defined by the student in consultation with me. For the
48 | final project, the student will define the questions he or she wants to
49 | answer, find the data to answer it, code up a solution to the question(s),
50 | and put together a presentation on the project and solution that will be
51 | presented during our final class. For the final project, discussion with
52 | classmates and me is encouraged as each student will define his or her own
53 | project and goals. The instructor will make himself available for virtual
54 | office hours weekly on Mondays from 4 to 5 PM using Zoom. If you have
55 | questions or concerns, don’t hesitate to meet with me during office hours,
56 | send me an email, or schedule an ad-hoc meeting with me outside of our
57 | regular meetings or office hours. For week 1 of class, please post your
58 | name, discipline of study, and academic interests in the Introductions
59 | discussion channel in Blackboard. If you ever need to talk, do not
60 | hesitate to reach out to me.
61 |
62 | # Schedule
63 | | Week | Topic |
64 | | ---- | ----- |
65 | | Week 1 | Intro to Python & Jupyter |
66 | | Week 2 | Intro to ```arcpy``` |
67 | | Week 3 | Exploring spatial data |
68 | | Week 4 | Working with feature data and cursors |
69 | | Week 5 | Working with features and geometries |
70 | | Week 6 | Rasters & imagery |
71 | | Week 7 | Creating Python script tools |
72 | | Week 8 | Functions, classes, and error handling |
73 | | Week 9 | Intro to Python for web GIS |
74 | | Week 10 | Interacting with AGOL using Python |
75 | | Week 11 | Publishing and consuming GIS services |
76 | | Week 12 | Plotting and data visualization |
77 | | Week 13 | Introduction to HTML and JavaScript |
78 | | Week 14 | Scientific data |
79 | | Week 15 | Final Project presentations |
80 |
81 | # Homework
82 | The purpose of the homework is twofold: to keep you thinking about
83 | Python outside of the lab and to prepare you for the next class.
84 | I do not want to overwhelm you with homework. I do want to ensure
85 | that you are learning how to use Python to solve GIS and remote
86 | sensing problems. Please do not hesitate to ask me or your classmates
87 | questions on homework if you are encountering difficulties. Furthermore,
88 | I would like your feedback as to whether assignments get too difficult or
89 | too easy so that I can adjust the assignments and in-class materials
90 | accordingly. Homework is to be submitted via blackboard before class on
91 | the day that it is due.
92 |
93 | # In Class Exercises
94 | The easiest way to learn to code is by writing code! Lectures are
95 | designed to be interactive. If I am typing code, you should be too!
96 | Lectures will be followed by in-class exercises that are designed to
97 | get you writing code on your own. The exercises that I have written
98 | as Python notebooks (.ipynb files) have questions throughout them.
99 | Please answer these questions and submit them via Blackboard before
100 | the beginning of the following week of class.
101 |
102 | # Project 1
103 | Project 1 will likely consist of working with
104 | tabular data (CSV or text file) or generating
105 | some report based on GIS data using Python.
106 | I will give the assignment by week 4. It is due
107 | before class on week 6.
108 |
109 | # Project 2
110 | Project 2 will likely consist of using Python to do some
111 | sort of spatial analysis or raster analysis. It will be
112 | assigned by week 9. It is due before class on week 11.
113 |
114 | # Final Project
115 | In my experience, all students and professionals need at
116 | least one demo or presentation that they can be prepared
117 | to give for a job interview, conference presentation, or
118 | other type of meeting. Through this class, I’d like each
119 | student to develop that demo or presentation, with the
120 | foundation of that presentation being some sort of spatial
121 | analysis, imagery analysis, or GIS analysis with Python.
122 | Each student will be responsible for a short 10 minute
123 | presentation to be given during either Week 14 or 15 of
124 | class on a project of their own choosing that will leverage
125 | Python. Before Spring Break (i.e. by Week 8), please submit
126 | to me a short write up (no more than 1 page) of what your
127 | project will be, what problem you will solve, how you will
128 | use Python to solve the problem. On week 14 or 15, please
129 | be prepared to give a 10 minute presentation explaining
130 | your problem, solution, how you got there, and hopefully
131 | some cool maps and results.
--------------------------------------------------------------------------------
/Unit 1/Lecture_1_Slides.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 1/Lecture_1_Slides.pptx
--------------------------------------------------------------------------------
/Unit 1/Missouri.gdb.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 1/Missouri.gdb.zip
--------------------------------------------------------------------------------
/Unit 1/README.md:
--------------------------------------------------------------------------------
1 | # This Week's Reading
2 | This week, please read the following:
3 | - Beginner's guide to Python in ArcGIS Pro, Part 1: Why?
4 | - Beginner’s guide to Python in ArcGIS Pro, Part 2: How?
5 | - Chapters 1 and Chapters 4 of Python Scripting for ArcGIS Pro
6 |
7 | # Last Year's Week 1 Lecture Recording
8 | Here are the links to the first lecture from last year. This link is not intended to be used in place of this week's lecture. I am providing it as an additional resource for extra context.
9 | - First half of lecture - https://slu.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=e01fab5b-e86b-4f7a-b584-ab41016e8a56
10 | - Second half of lecture - https://slu.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=d55b6de0-817d-479d-86d6-ab410188ecf4
11 |
12 | # Presentations
13 | Here are the PowerPoint slides that I plan to use for week 1.
14 | Attached Files:
15 |
16 | File Lecture_1_Slides.pptx Click for more options (2.058 MB)
17 | File Welcome.pptx Click for more options (515.31 KB)
18 |
19 | # Data and Notebooks
20 | This week's lecture notebooks can be found in the [GIS 4090\5090 Unit 1 Notebooks](This week's lecture notebooks can be found in the GIS 4090\5090 Unit 1 Notebooks group on ArcGIS Online or downloaded here. Please download the Missouri.gdb.zip so that we can use it for the lecture.)
21 | group on ArcGIS Online or downloaded here.
22 | Please download the Missouri.gdb.zip so that we can use it for the lecture.
23 | Attached Files:
24 |
25 | File unit_1_lesson_1_introto_python.ipynb Click for more options (36.852 KB)
26 | File unit_1_lesson_2_more_python.ipynb Click for more options (19.851 KB)
27 | File Missouri.gdb.zip Click for more options (10.712 MB)
28 |
29 | # Configuring Jupyter Notebooks
30 | This document provides instructions to configure Jupyter Notebooks on your computer. We will go through this process
31 | to setup Jupyter Notebooks on your lab computer or personal computer.
32 | Attached Files:
33 |
34 | File configuring_the_notebook_directory.html Click for more options (269.886 KB)
35 |
36 | # Unit 1 Exercise and Discussion Questions
37 | ## Exercises
38 |
39 | Before completing the assignment, I recommend completing the following exercises. Completing these 3 exercises should not take more than an hour.
40 |
41 | Complete the Hello, Notebook !exercise. After you complete it, add another map object and a different dataset to the map. Save the Notebook and share the link to the Notebook here. I will be able to see your notebook even if you don't explicitly share it with me in ArcGIS Online because I am an administrator in the ArcGIS Online organization.
42 | Please complete Python Scripting for ArcGIS Pro Exercise 1. This should take no more than 15 minutes.
43 | Please complete Python Scripting for ArcGIS Pro Exercise 4. This will take a little bit longer but I think you will find it very helpful. Please submit the Python scripts that you create.
44 |
45 | ## Discussion Questions
46 |
47 | Please submit a Word file or text file that answers the following questions.
48 |
49 | What is the version Python that comes with ArcGIS Pro?
50 | Name 3 methods of string objects in Python and give an example of each.
51 | What two values can a boolean take on?
52 | How do you denote a comment line in Python and what should yo use comments?
53 |
54 | # Unit 1 Assignment
55 | ## Assignment
56 |
57 | Please submit a Word file, text file, or ArcGIS Notebook that answers the following questions. If you do this in ArcGIS Notebooks, you can save the notebook and just send me a URL to the item in ArcGIS Online.
58 |
59 | 1. Consider the following variable called happyCow
60 |
61 | happyCow = 'meadows.shp'
62 |
63 | Determine the following:
64 |
65 | happyCow[0]
66 | happyCow[0:5] + happyCow[-4:]
67 | len(happyCow)
68 | happyCow[0:5]
69 | happyCow[-4:]
70 | happyCow[11]
71 | happyCow[:5]
72 | happyCow in "5meadows.shp"
73 | happyCow[5]
74 | 'W' in happyCow
75 |
76 |
77 | 2. Determine if each statement is True or False using the variable LCS_ID = '0017238'
78 |
79 | '17' in LCS_ID
80 | LCS_ID.isdigit()
81 | LCS_ID.lstrip('0') == '17238'
82 | LCS_ID.zfill(10) == '10101010'
83 | LCS_ID + '10' == 17248
84 | LCS_ID[6] == '3'
85 | len(LCS_ID) == 7
86 | LCS_ID[0:7] == '0017238'
87 | int(LCS_ID) + 10 == 17248
88 | LCS_ID != 17238
89 |
90 | 3. The list variable 'census' is as follows:
91 |
92 | census = ['4', '3', '79', '1', '66', '9', '1']
93 |
94 | Determine the following:
95 |
96 | len(census)
97 | census.insert(0,2)
98 | census.append(2)
99 | census.remove('1')
100 | census = '0'.join(census)
101 | census.pop(3)
102 | census.count('1')
103 | census.sort()
104 | census.reverse()
105 |
106 |
107 | 4. Consider the following list:
108 |
109 | mylist = ["Athens", "Barcelona", "Cairo", "Florence", "Helsinki"]
110 |
111 | Determine the results of the following:
112 |
113 | len(mylist)
114 | mylist[2]
115 | mylist[1:]
116 | mylist[-1]
117 | mylist.index("Cairo")
118 | mylist.pop(1)
119 | mylist.sort(reverse = True)
120 | mylist.append("Berlin")
121 |
122 | These operations are all to be performed on the original list—that is, not as a sequence of operations. Try to determine the answer manually first, and then check your result by running the code.
123 |
--------------------------------------------------------------------------------
/Unit 1/Welcome.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 1/Welcome.pptx
--------------------------------------------------------------------------------
/Unit 1/unit_1_lesson_2_more_python.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# More Python Fundamentals"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "In these excercises, we will address more of what I consider Python fundamentals."
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "## File Paths"
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": [
28 | "File paths in Python can seem very peculiar to newcomers to programming. Typically, we see a filpath represented as something like C:\\Documents\\my_document.docx. In Python, we can not just reference a file this way. Let's walk through the 3 ways we can reference file names in Python using the week 1 or week 2 excercise data."
29 | ]
30 | },
31 | {
32 | "cell_type": "code",
33 | "execution_count": null,
34 | "metadata": {
35 | "collapsed": true
36 | },
37 | "outputs": [],
38 | "source": [
39 | "input_fc = \"C:\\\\Users\\\\greg6750\\\\Documents\\\\IPython Notebooks\\\\Python_for_GIS_and_RS\\\\Week_1\\\\data\\\\Missouri.gdb\\\\County\""
40 | ]
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "metadata": {},
45 | "source": [
46 | "Let's print out input_fc to see how Python interprets that."
47 | ]
48 | },
49 | {
50 | "cell_type": "code",
51 | "execution_count": null,
52 | "metadata": {},
53 | "outputs": [],
54 | "source": [
55 | "print(input_fc)"
56 | ]
57 | },
58 | {
59 | "cell_type": "markdown",
60 | "metadata": {},
61 | "source": [
62 | "Notice that Python has removed the double backslashes. Rather than using double backslashes, we could use single forward slashes as follows."
63 | ]
64 | },
65 | {
66 | "cell_type": "code",
67 | "execution_count": null,
68 | "metadata": {
69 | "collapsed": true
70 | },
71 | "outputs": [],
72 | "source": [
73 | "input_fc = \"C:/Users/greg6750/Documents/IPython Notebooks/Python_for_GIS_and_RS/Week_1/data/Missouri.gdb/County\""
74 | ]
75 | },
76 | {
77 | "cell_type": "markdown",
78 | "metadata": {},
79 | "source": [
80 | "Now, when we print that out we see that Python shows a single forward slash."
81 | ]
82 | },
83 | {
84 | "cell_type": "code",
85 | "execution_count": null,
86 | "metadata": {},
87 | "outputs": [],
88 | "source": [
89 | "print(input_fc)"
90 | ]
91 | },
92 | {
93 | "cell_type": "markdown",
94 | "metadata": {},
95 | "source": [
96 | "The final way to reference file path is by placeing the letter _r_ in front of the string. This indicates to Python that the single backslash not be read as an escape character."
97 | ]
98 | },
99 | {
100 | "cell_type": "code",
101 | "execution_count": null,
102 | "metadata": {
103 | "collapsed": true
104 | },
105 | "outputs": [],
106 | "source": [
107 | "input_fc = r\"C:\\Users\\greg6750\\Documents\\IPython Notebooks\\Python_for_GIS_and_RS\\Week_1\\data\\Missouri.gdb\\County\""
108 | ]
109 | },
110 | {
111 | "cell_type": "markdown",
112 | "metadata": {},
113 | "source": [
114 | "Now, when we print this string out, we should see single backslashes."
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "metadata": {},
121 | "outputs": [],
122 | "source": [
123 | "print(input_fc)"
124 | ]
125 | },
126 | {
127 | "cell_type": "markdown",
128 | "metadata": {},
129 | "source": [
130 | "## Modules"
131 | ]
132 | },
133 | {
134 | "cell_type": "markdown",
135 | "metadata": {
136 | "collapsed": true
137 | },
138 | "source": [
139 | "Modules are functionality that can be imported into Python to extend its capabilities. Here, we will import and examine a few modules that we will use in the future."
140 | ]
141 | },
142 | {
143 | "cell_type": "code",
144 | "execution_count": null,
145 | "metadata": {
146 | "collapsed": true
147 | },
148 | "outputs": [],
149 | "source": [
150 | "import arcpy"
151 | ]
152 | },
153 | {
154 | "cell_type": "markdown",
155 | "metadata": {},
156 | "source": [
157 | "Let's see what version of arcpy we're using."
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "metadata": {},
164 | "outputs": [],
165 | "source": [
166 | "arcpy.GetInstallInfo()"
167 | ]
168 | },
169 | {
170 | "cell_type": "markdown",
171 | "metadata": {},
172 | "source": [
173 | "## Question 1: What is the version number of arcpy?"
174 | ]
175 | },
176 | {
177 | "cell_type": "markdown",
178 | "metadata": {},
179 | "source": [
180 | "You can also print out the help for each function using the __doc__ command. Let's see what the ArcGIS Documentation says about the [Clip function](http://pro.arcgis.com/en/pro-app/tool-reference/analysis/clip.htm)"
181 | ]
182 | },
183 | {
184 | "cell_type": "code",
185 | "execution_count": null,
186 | "metadata": {},
187 | "outputs": [],
188 | "source": [
189 | "arcpy.Clip_analysis.__doc__"
190 | ]
191 | },
192 | {
193 | "cell_type": "markdown",
194 | "metadata": {},
195 | "source": [
196 | "We can also list out all of the functions within the arcpy library using the __dir__ command."
197 | ]
198 | },
199 | {
200 | "cell_type": "code",
201 | "execution_count": null,
202 | "metadata": {},
203 | "outputs": [],
204 | "source": [
205 | "dir(arcpy)"
206 | ]
207 | },
208 | {
209 | "cell_type": "markdown",
210 | "metadata": {},
211 | "source": [
212 | "We can count the number of functions in the arcpy module using the __len__ function,"
213 | ]
214 | },
215 | {
216 | "cell_type": "code",
217 | "execution_count": null,
218 | "metadata": {},
219 | "outputs": [],
220 | "source": [
221 | "len(dir(arcpy))"
222 | ]
223 | },
224 | {
225 | "cell_type": "markdown",
226 | "metadata": {},
227 | "source": [
228 | "## Question 2: How many functions are there in arcpy?"
229 | ]
230 | },
231 | {
232 | "cell_type": "markdown",
233 | "metadata": {},
234 | "source": [
235 | "Another module that we'll be using is the _time_ module. This will help us track how long processes take to run, how to manipulate strings that contain time or data information, and much more. Let's import _time_."
236 | ]
237 | },
238 | {
239 | "cell_type": "code",
240 | "execution_count": null,
241 | "metadata": {
242 | "collapsed": true
243 | },
244 | "outputs": [],
245 | "source": [
246 | "import time"
247 | ]
248 | },
249 | {
250 | "cell_type": "markdown",
251 | "metadata": {},
252 | "source": [
253 | "We can get the locatime using this time object module."
254 | ]
255 | },
256 | {
257 | "cell_type": "code",
258 | "execution_count": null,
259 | "metadata": {},
260 | "outputs": [],
261 | "source": [
262 | "time.localtime()"
263 | ]
264 | },
265 | {
266 | "cell_type": "markdown",
267 | "metadata": {},
268 | "source": [
269 | "This function returned a tuple containing year, month, day, hour, min, sec, etc. describing the local time. An easier way to represent time would be as asctime."
270 | ]
271 | },
272 | {
273 | "cell_type": "code",
274 | "execution_count": null,
275 | "metadata": {},
276 | "outputs": [],
277 | "source": [
278 | "time.asctime()"
279 | ]
280 | },
281 | {
282 | "cell_type": "markdown",
283 | "metadata": {},
284 | "source": [
285 | "## Conditoinal Statements"
286 | ]
287 | },
288 | {
289 | "cell_type": "markdown",
290 | "metadata": {},
291 | "source": [
292 | "Conditional statements, also knows as if/else statements, are common to all programming languages. COnditional statements evaluate data, and make a decision based on the result. Let's write a few if/else statements.\n",
293 | "\n",
294 | "Python has a module called _random_ which can be used to generate random numbers. Here we can similate a coinflip using random. Import random."
295 | ]
296 | },
297 | {
298 | "cell_type": "code",
299 | "execution_count": null,
300 | "metadata": {
301 | "collapsed": true
302 | },
303 | "outputs": [],
304 | "source": [
305 | "import random"
306 | ]
307 | },
308 | {
309 | "cell_type": "markdown",
310 | "metadata": {},
311 | "source": [
312 | "We can generate a random number that is either 1 or 2 using the _randint_ function. If the number is 1, we say the number is odd. If the number is 2 we say the number is even. Try the following code."
313 | ]
314 | },
315 | {
316 | "cell_type": "code",
317 | "execution_count": null,
318 | "metadata": {},
319 | "outputs": [],
320 | "source": [
321 | "random_val = random.randint(1, 2)\n",
322 | "if random_val == 1:\n",
323 | " print(str(random_val) + \" is Odd\")\n",
324 | "else: \n",
325 | " print(str(random_val) + \" is Even\")"
326 | ]
327 | },
328 | {
329 | "cell_type": "markdown",
330 | "metadata": {},
331 | "source": [
332 | "Let's write a conditional statement that evaluates a list of data. Type and execute the following code."
333 | ]
334 | },
335 | {
336 | "cell_type": "code",
337 | "execution_count": null,
338 | "metadata": {},
339 | "outputs": [],
340 | "source": [
341 | "data = [1,2,3,4,5,6,7,8,9,10]\n",
342 | "for val in data:\n",
343 | " if val % 2 == 0:\n",
344 | " print(val,\"No remainder\") # the % sign is the modulus operator and tests for a remainder\n",
345 | " elif val % 3 == 2:\n",
346 | " print(val,\"Remainder of Two\")\n",
347 | " else:\n",
348 | " print(\"Final Case\")"
349 | ]
350 | },
351 | {
352 | "cell_type": "markdown",
353 | "metadata": {},
354 | "source": [
355 | "COnditional statements are very powerful. You will be using the a lot! [Check out this site to learn more about the comparison operators and logical operators n Python](https://www.tutorialspoint.com/python/python_basic_operators.htm)"
356 | ]
357 | },
358 | {
359 | "cell_type": "markdown",
360 | "metadata": {},
361 | "source": [
362 | "## Loops"
363 | ]
364 | },
365 | {
366 | "cell_type": "markdown",
367 | "metadata": {},
368 | "source": [
369 | "### While Loops"
370 | ]
371 | },
372 | {
373 | "cell_type": "markdown",
374 | "metadata": {},
375 | "source": [
376 | "Truth be told, I never use while loops! This might actually be the first one I've written in Python. This is because I find _for_ loops and conditional statements more intuitive. That being said, let's take our random number generator example and run it 10 times using a while loop and see what answers we get."
377 | ]
378 | },
379 | {
380 | "cell_type": "code",
381 | "execution_count": null,
382 | "metadata": {},
383 | "outputs": [],
384 | "source": [
385 | "import random\n",
386 | "\n",
387 | "i = 1\n",
388 | "while i <= 10:\n",
389 | " random_val = random.randint(1, 2)\n",
390 | " if random_val == 1:\n",
391 | " print(\"Trial \" + str(i) + \": \" + str(random_val) + \" is Odd\")\n",
392 | " else: \n",
393 | " print(\"Trial \" + str(i) + \": \" + str(random_val) + \" is Even\")\n",
394 | " i += 1"
395 | ]
396 | },
397 | {
398 | "cell_type": "markdown",
399 | "metadata": {},
400 | "source": [
401 | "## Question 3: How many odd and how many even results did you get over 10 Trials?"
402 | ]
403 | },
404 | {
405 | "cell_type": "markdown",
406 | "metadata": {},
407 | "source": [
408 | "In the example above, the trials are run while the value of _i_ is less than 10. Once the 10th trial is hit, Python exits out of the loop."
409 | ]
410 | },
411 | {
412 | "cell_type": "markdown",
413 | "metadata": {},
414 | "source": [
415 | "### For Loops"
416 | ]
417 | },
418 | {
419 | "cell_type": "markdown",
420 | "metadata": {},
421 | "source": [
422 | "Like I mentioned above, I prefer using for loops to while loops. For loops repeat parts of your code but are not tied to a specific condition. We will encounter for loops throughout our programming careers and understanding them will be key to your growth as a programmer or developer. Let's write a few for loops."
423 | ]
424 | },
425 | {
426 | "cell_type": "code",
427 | "execution_count": null,
428 | "metadata": {
429 | "collapsed": true
430 | },
431 | "outputs": [],
432 | "source": [
433 | "top_five = [\"Patriots\", \"Seahawks\", \"Cowboys\", \"Chiefs\", \"Steelers\"]"
434 | ]
435 | },
436 | {
437 | "cell_type": "markdown",
438 | "metadata": {},
439 | "source": [
440 | "Here we've created a list of the top 5 teams in the NFL (hypothetical). We can print out each team name using a for loop."
441 | ]
442 | },
443 | {
444 | "cell_type": "code",
445 | "execution_count": null,
446 | "metadata": {},
447 | "outputs": [],
448 | "source": [
449 | "for team in top_five:\n",
450 | " print(team)"
451 | ]
452 | },
453 | {
454 | "cell_type": "markdown",
455 | "metadata": {},
456 | "source": [
457 | "We can print out each team name in all caps using the _upper_ function."
458 | ]
459 | },
460 | {
461 | "cell_type": "code",
462 | "execution_count": null,
463 | "metadata": {},
464 | "outputs": [],
465 | "source": [
466 | "for team in top_five:\n",
467 | " print(team.upper())"
468 | ]
469 | },
470 | {
471 | "cell_type": "markdown",
472 | "metadata": {},
473 | "source": [
474 | "A practical application of for loops is that we can list all datasets in a folder or geodatabase. Packaged in the Week 2 folder we have a census dataset. Let's import the census dataset using arcpy and list all of the feature classes in the census geodatabase. "
475 | ]
476 | },
477 | {
478 | "cell_type": "code",
479 | "execution_count": null,
480 | "metadata": {},
481 | "outputs": [],
482 | "source": [
483 | "import arcpy\n",
484 | "\n",
485 | "arcpy.env.workspace = r'C:\\Users\\greg6750\\Documents\\IPython Notebooks\\Python_for_GIS_and_RS\\Week_2\\data\\tlgdb_2016_a_44_ri.gdb'\n",
486 | "\n",
487 | "fcs = arcpy.ListFeatureClasses()\n",
488 | "\n",
489 | "for fc in fcs:\n",
490 | " print(fc)"
491 | ]
492 | },
493 | {
494 | "cell_type": "markdown",
495 | "metadata": {},
496 | "source": [
497 | "Here, we imported arcpy. We set the arcpy environment to be the census geodatabase. We used ListFeatureClasses to create a list of feature classes in the geodatabase, and we printed out the names of each feature class. We can also print out the number of features in the geodatabase."
498 | ]
499 | },
500 | {
501 | "cell_type": "code",
502 | "execution_count": null,
503 | "metadata": {},
504 | "outputs": [],
505 | "source": [
506 | "print(len(fcs))"
507 | ]
508 | },
509 | {
510 | "cell_type": "markdown",
511 | "metadata": {},
512 | "source": [
513 | "## Question 4: How many feature classes are in that geodatabase?"
514 | ]
515 | },
516 | {
517 | "cell_type": "markdown",
518 | "metadata": {},
519 | "source": [
520 | "## OS"
521 | ]
522 | },
523 | {
524 | "cell_type": "markdown",
525 | "metadata": {},
526 | "source": [
527 | "The [_os_ module](https://docs.python.org/2/library/os.html) allows Python users to interact with their computer's operating system. This includes accessing directories, files, and other data on the OS. It is a library that you will use very often to find files, move files, create file path, and more. Here, we'll introduce you to a few ways to use OS."
528 | ]
529 | },
530 | {
531 | "cell_type": "code",
532 | "execution_count": null,
533 | "metadata": {
534 | "collapsed": true
535 | },
536 | "outputs": [],
537 | "source": [
538 | "import os"
539 | ]
540 | },
541 | {
542 | "cell_type": "markdown",
543 | "metadata": {},
544 | "source": [
545 | "Let's take one of the filenames that we've used above."
546 | ]
547 | },
548 | {
549 | "cell_type": "code",
550 | "execution_count": null,
551 | "metadata": {
552 | "collapsed": true
553 | },
554 | "outputs": [],
555 | "source": [
556 | "missouri_gdb = r\"C:\\Users\\greg6750\\Documents\\IPython Notebooks\\Python_for_GIS_and_RS\\Week_1\\data\\Missouri.gdb\""
557 | ]
558 | },
559 | {
560 | "cell_type": "markdown",
561 | "metadata": {},
562 | "source": [
563 | "We can use os to split that path into geodatabase and the path to the geodatabase as follows:"
564 | ]
565 | },
566 | {
567 | "cell_type": "code",
568 | "execution_count": null,
569 | "metadata": {},
570 | "outputs": [],
571 | "source": [
572 | "os.path.basename(missouri_gdb) #returns the geodatabase"
573 | ]
574 | },
575 | {
576 | "cell_type": "code",
577 | "execution_count": null,
578 | "metadata": {},
579 | "outputs": [],
580 | "source": [
581 | "os.path.dirname(missouri_gdb) #returns the directory"
582 | ]
583 | },
584 | {
585 | "cell_type": "markdown",
586 | "metadata": {},
587 | "source": [
588 | "You could also use:"
589 | ]
590 | },
591 | {
592 | "cell_type": "code",
593 | "execution_count": null,
594 | "metadata": {},
595 | "outputs": [],
596 | "source": [
597 | "path, gdb = os.path.split(missouri_gdb)\n",
598 | "print(path) #returns the path\n",
599 | "print(gdb) #returns the geodatabase"
600 | ]
601 | },
602 | {
603 | "cell_type": "markdown",
604 | "metadata": {},
605 | "source": [
606 | "Another cool function in _os_ is _walk_. Walk can be used to list all of the files in a directory. Choose a directory on your machine and try it!"
607 | ]
608 | },
609 | {
610 | "cell_type": "code",
611 | "execution_count": null,
612 | "metadata": {},
613 | "outputs": [],
614 | "source": [
615 | "folder = r'C:\\Users\\greg6750\\Documents\\IPython Notebooks\\Python_for_GIS_and_RS\\Week_1'\n",
616 | "for (path, dirs, files) in os.walk(folder):\n",
617 | " print(path)\n",
618 | " print(dirs)\n",
619 | " print(files)"
620 | ]
621 | },
622 | {
623 | "cell_type": "markdown",
624 | "metadata": {},
625 | "source": [
626 | "This should list everything you find in the folder, including subsolders!"
627 | ]
628 | },
629 | {
630 | "cell_type": "markdown",
631 | "metadata": {},
632 | "source": [
633 | "## SYS"
634 | ]
635 | },
636 | {
637 | "cell_type": "markdown",
638 | "metadata": {},
639 | "source": [
640 | "The [_sys_ module](https://docs.python.org/2/library/sys.html) provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. Here, we'll learn a few common ways that you might use _sys_."
641 | ]
642 | },
643 | {
644 | "cell_type": "code",
645 | "execution_count": null,
646 | "metadata": {
647 | "collapsed": true
648 | },
649 | "outputs": [],
650 | "source": [
651 | "import sys"
652 | ]
653 | },
654 | {
655 | "cell_type": "markdown",
656 | "metadata": {},
657 | "source": [
658 | "You can use _sys.path_ to look at your Windows path variable."
659 | ]
660 | },
661 | {
662 | "cell_type": "code",
663 | "execution_count": null,
664 | "metadata": {},
665 | "outputs": [],
666 | "source": [
667 | "print(sys.path)"
668 | ]
669 | },
670 | {
671 | "cell_type": "markdown",
672 | "metadata": {},
673 | "source": [
674 | "We can search for Python in our system path variable. If it is in there, we should be able to execute python from the Windows command prompt."
675 | ]
676 | },
677 | {
678 | "cell_type": "code",
679 | "execution_count": null,
680 | "metadata": {},
681 | "outputs": [],
682 | "source": [
683 | "path = sys.path\n",
684 | "for element in path:\n",
685 | " if 'python' in element:\n",
686 | " print(\"Python is in our Path variable!\")"
687 | ]
688 | },
689 | {
690 | "cell_type": "markdown",
691 | "metadata": {},
692 | "source": [
693 | "## Question 5: Is Python in your path variable?"
694 | ]
695 | },
696 | {
697 | "cell_type": "markdown",
698 | "metadata": {},
699 | "source": [
700 | "If Python is in your path, you should be able to run python from your command prompt as follows: \n",
701 | "\n",
702 | "If it's not, we can add Python to our system path as follows.\n",
703 | "1. Go to your system properties.\n",
704 | "\n",
705 | "2. Open your environment variables.\n",
706 | "\n",
707 | "3. Select Path and click 'Edit'.\n",
708 | "\n",
709 | "4. Add the location of the python.exe file (usually something like C:\\Python27\\ArcGIS10.3\\python.exe) to your path.\n",
710 | "\n",
711 | "Now, you should be able to type 'python' at the command prompt and enter a python session. "
712 | ]
713 | },
714 | {
715 | "cell_type": "markdown",
716 | "metadata": {},
717 | "source": [
718 | "## Getting User Input"
719 | ]
720 | },
721 | {
722 | "cell_type": "markdown",
723 | "metadata": {},
724 | "source": [
725 | "A common way for python scripts to take user input is to use the sys module. In the Week 2 materials, you should see a addition.py file. The only code in that file is the following."
726 | ]
727 | },
728 | {
729 | "cell_type": "code",
730 | "execution_count": null,
731 | "metadata": {},
732 | "outputs": [],
733 | "source": [
734 | "import sys\n",
735 | "\n",
736 | "var1 = int(sys.argv[1])\n",
737 | "var2 = int(sys.argv[2])\n",
738 | "\n",
739 | "print('The answer is ' + str(var1+var2))"
740 | ]
741 | },
742 | {
743 | "cell_type": "markdown",
744 | "metadata": {
745 | "collapsed": true
746 | },
747 | "source": [
748 | "If this code is run at the command line as follows.\n",
749 | "\n",
750 | "Notice that the command line arguments get entered immediately after the script name and they are separated by spaces. Try is out!"
751 | ]
752 | },
753 | {
754 | "cell_type": "markdown",
755 | "metadata": {},
756 | "source": [
757 | "## Guidenlines for Python Coding"
758 | ]
759 | },
760 | {
761 | "cell_type": "markdown",
762 | "metadata": {},
763 | "source": [
764 | "First things first:"
765 | ]
766 | },
767 | {
768 | "cell_type": "code",
769 | "execution_count": null,
770 | "metadata": {},
771 | "outputs": [],
772 | "source": [
773 | "import this"
774 | ]
775 | },
776 | {
777 | "cell_type": "markdown",
778 | "metadata": {},
779 | "source": [
780 | "Take these recommendations into account while coding!\n",
781 | "\n",
782 | "Additionally, Python has what is called [PEP 8 - Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/). The '8' is becuase this is version 8. Let's check it out. Not every recommendation here is madatory, but they should definately be considered best pratices."
783 | ]
784 | }
785 | ],
786 | "metadata": {
787 | "anaconda-cloud": {},
788 | "kernelspec": {
789 | "display_name": "Python 3",
790 | "language": "python",
791 | "name": "python3"
792 | },
793 | "language_info": {
794 | "codemirror_mode": {
795 | "name": "ipython",
796 | "version": 3
797 | },
798 | "file_extension": ".py",
799 | "mimetype": "text/x-python",
800 | "name": "python",
801 | "nbconvert_exporter": "python",
802 | "pygments_lexer": "ipython3",
803 | "version": "3.6.9"
804 | }
805 | },
806 | "nbformat": 4,
807 | "nbformat_minor": 1
808 | }
809 |
--------------------------------------------------------------------------------
/Unit 10/README.md:
--------------------------------------------------------------------------------
1 | # Watch these videos
2 | - [ArcGIS API for Python: Introduction to Scripting your Web GIS](https://www.youtube.com/watch?v=WSXzlpVZM50)
3 | - [ArcGIS Python API for Administrators and Content Publishers](https://www.youtube.com/watch?v=4AzOodYTHs4)
4 |
5 | # This weeks notebooks
6 | This weeks notebooks are in ArcGIs Online at
7 | [GIS 4090\5090 Unit 10 Notebooks](https://slustl.maps.arcgis.com/home/group.html?id=dd378276497c4d9994ffc50be5c15d8d#overview)
8 |
9 | We will use the same datasets that we used last week.
10 |
11 | # Lecture
12 |
13 | ## Let's take a step back...
14 | 1. Searching Content in AGOL
15 | 2. Renderers and Publishing a CSV
16 |
17 | ## Administering ArcGIS Online
18 | 1. Go to ArcGIS Online.
19 | 2. Show users the *Overview* tab.
20 | 3. Show users the *Members* tab.
21 | 4. Show *Licenses*, *Status*, and *Settings* tabs.
22 | 5. Go to user: Gregory Brunner
23 | 6. Show students options to change on their personal user info.
24 | 7. Show students *Groups*.
25 | 8. Create a new *Group*.
26 | 9. Invite the students.
27 | 10. Add Content to the *Group*.
28 |
29 | # ArcGIS API for Python
30 | To learn more about the ArcGIS API for Python, go to https://developers.arcgis.com/python/
31 |
32 | # ArcGIS API for Python Samples
33 | To see more samples of how to use the ArcGIS API for Python go to https://developers.arcgis.com/python/sample-notebooks/
34 |
35 | # Unit 10 Exercise and Discussion Questions
36 | ## Problem 1
37 | Create a new Jupyter Notebook or ArcGIS Notebook that:
38 | 1. Contains a map
39 | 2. Zooms to a particular city of interest
40 | 3. Changes the basemap from the default Terrain basemap
41 | 4. Please use Markdown to apply meaningful descriptions of your steps.
42 | 5. Contains at least 3 layers, not including the basemap
43 |
44 | ## Problem 2
45 | 2. Using the ArcGIS API for Python and following from the examples in class, geocode the addresses in the addresses.csv. Add them to a map. Save the map as a webmap. What is the common theme among the addresses?
46 |
47 | Attached Files:
48 |
49 | File addresses.csv Click for more options (438 B)
50 |
--------------------------------------------------------------------------------
/Unit 10/addresses.csv:
--------------------------------------------------------------------------------
1 | Single Line Address
2 | "470 E Lockwood Ave, Webster Groves, MO 63119"
3 | "1 Brookings Dr, St. Louis, MO 63130"
4 | "1 N Grand Blvd, St. Louis, MO 63103"
5 | "1 Hairpin Dr, Edwardsville, IL 62026"
6 | "1263 Lincoln Dr, Carbondale, IL 62901"
7 | "1 University Blvd, St. Louis, MO 63121"
8 | "5000 Holmes St, Kansas City, MO 64110"
9 | "6823 St Charles Ave, New Orleans, LA 70118"
10 | "300 College Park, Dayton, OH 45469"
11 | "2807 N Glebe Rd, Arlington, VA 22207"
12 |
--------------------------------------------------------------------------------
/Unit 11/README.md:
--------------------------------------------------------------------------------
1 | # This week's lectures
2 | This week's lecture notebooks can be found in
3 | ArcGIS Online at [GIS 4090\5090 Unit 11 Notebooks](https://slustl.maps.arcgis.com/home/group.html?id=b3d8431a10c64970b43e4ff59dd083d6#overview)
4 |
5 | # Data for this week
6 | Here are a few datasets that we will use this week:
7 |
8 | File Thunder_Departures_gjb.csv Click for more options (1.215 KB)
9 | File Thunder_Acquisitions_gjb.csv Click for more options (1.304 KB)
10 | File STL_Crime_gjb.gdb.zip Click for more options (640.133 KB)
11 | File STL_Crime_1.gdb.zip Click for more options (640.133 KB)
12 | File nbrhds_wards_demo1.zip Click for more options (179.985 KB)
13 | File national_rainfall_data_demogjb.zip Click for more options (992.424 KB)
14 |
15 | # Supplemental materials
16 | If you are new to hex codes and colors, you can learn more on [the colorwheel](https://www.colorspire.com/rgb-color-wheel/).
17 |
18 | # Unit 11 Exercise and Discussion Questions
19 | Please complete the following for homework:
20 | 1. For context, [read this tutorial on Adding Spreadsheet data to ArcGIS Online.](https://www.esri.com/arcgis-blog/products/arcgis-online/data-management/add-spreadsheet-data-to-arcgis-online/)
21 | 2. Optionally, [watch the videos in Symbolize Data and Publish Maps.](https://learn.arcgis.com/en/paths/symbolize-data-and-publish-maps/)
22 | 3. Download the attached CSVs. Rename them to "Thunder_Departed_" followed by
23 | your initials and ".csv" and "Thunder_Acquisitions_" followed by your initials
24 | and ".csv". Create a notebook that geocodes those CSVs of addresses and adds
25 | each to the same map object with a different symbology
26 | (see [this tutorial](https://developers.arcgis.com/python/sample-notebooks/publishing-sd-shapefiles-and-csv/#Publish-a-CSV-file-and-move-it-into-a-folder)
27 | if you need help). Save this as a webmap following from [this
28 | example](https://developers.arcgis.com/python/guide/working-with-web-maps-and-web-scenes/#Saving-or-Updating-a-web-map).
29 | Be sure to go to ArcGIS online and check that the Webmap is there!
30 |
31 | **Hint:** You can change the symbology by changing the renderer.
32 | For example, if you change the color values in this renderer, the points will
33 | change color accordingly.
34 |
35 | simple_renderer = {
36 | "renderer": {
37 | "type": "simple",
38 | "symbol": {
39 | "color": [
40 | 0,
41 | 0,
42 | 128,
43 | 128
44 | ],
45 | "size": 15,
46 | "angle": 0,
47 | "xoffset": 0,
48 | "yoffset": 0,
49 | "type": "esriSMS",
50 | "style": "esriSMSCircle",
51 | "outline": {
52 | "color": [
53 | 0,
54 | 0,
55 | 128,
56 | 255
57 | ],
58 | "width": 0.99975,
59 | "type": "esriSLS",
60 | "style": "esriSLSSolid"
61 | }
62 | }
63 | }
64 | }
65 |
66 | map1.add_layer(acled, simple_renderer)
--------------------------------------------------------------------------------
/Unit 11/STL_Crime_1.gdb.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 11/STL_Crime_1.gdb.zip
--------------------------------------------------------------------------------
/Unit 11/STL_Crime_gjb.gdb.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 11/STL_Crime_gjb.gdb.zip
--------------------------------------------------------------------------------
/Unit 11/Thunder_Acquisitions_gjb.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 11/Thunder_Acquisitions_gjb.csv
--------------------------------------------------------------------------------
/Unit 11/Thunder_Departures_gjb.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 11/Thunder_Departures_gjb.csv
--------------------------------------------------------------------------------
/Unit 11/national_rainfall_data_demogjb.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 11/national_rainfall_data_demogjb.zip
--------------------------------------------------------------------------------
/Unit 11/nbrhds_wards_demo1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 11/nbrhds_wards_demo1.zip
--------------------------------------------------------------------------------
/Unit 12/Lecture 2 - Intro to Spatial Dataframes (Feature to CSV in Lat and Longitude).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Remember that Crime CSV file we used to make a webapp earlier in the semester?"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "## Let's import the SpatialDataFrame"
15 | ]
16 | },
17 | {
18 | "cell_type": "code",
19 | "execution_count": 5,
20 | "metadata": {},
21 | "outputs": [],
22 | "source": [
23 | "import arcgis\n",
24 | "from arcgis.features import GeoAccessor as ga"
25 | ]
26 | },
27 | {
28 | "cell_type": "markdown",
29 | "metadata": {},
30 | "source": [
31 | "## We can read a feature class directly into a Dataframe"
32 | ]
33 | },
34 | {
35 | "cell_type": "code",
36 | "execution_count": 6,
37 | "metadata": {},
38 | "outputs": [],
39 | "source": [
40 | "#Or C:\\Users\\greg6750\\Documents\\IPython Notebooks\\Advanced_Python_for_GIS_and_RS\\Week 9\\crime_data.gdb\\STL_CRIME_POINTS_CopyFeature1\n",
41 | "sdf = ga.from_featureclass(\n",
42 | " r\"crime_data.gdb\\STL_CRIME_POINTS_CopyFeature1\"\n",
43 | ")"
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {},
49 | "source": [
50 | "## Let's look at the first 5 Values in the dataframe"
51 | ]
52 | },
53 | {
54 | "cell_type": "code",
55 | "execution_count": 7,
56 | "metadata": {},
57 | "outputs": [
58 | {
59 | "data": {
60 | "text/html": [
61 | "
\n",
62 | "\n",
75 | "
\n",
76 | " \n",
77 | "
\n",
78 | "
\n",
79 | "
OBJECTID
\n",
80 | "
Complaint
\n",
81 | "
CodedMonth
\n",
82 | "
DateOccur
\n",
83 | "
FlagCrime
\n",
84 | "
FlagUnfounded
\n",
85 | "
FlagAdministrative
\n",
86 | "
Count
\n",
87 | "
FlagCleanup
\n",
88 | "
Crime
\n",
89 | "
...
\n",
90 | "
ILEADSAddress
\n",
91 | "
ILEADSStreet
\n",
92 | "
Neighborhood
\n",
93 | "
LocationName
\n",
94 | "
LocationComment
\n",
95 | "
CADAddress
\n",
96 | "
CADStreet
\n",
97 | "
XCoord
\n",
98 | "
YCoord
\n",
99 | "
SHAPE
\n",
100 | "
\n",
101 | " \n",
102 | " \n",
103 | "
\n",
104 | "
0
\n",
105 | "
1
\n",
106 | "
16-060225
\n",
107 | "
2016-11
\n",
108 | "
2013-01-01 09:37:00
\n",
109 | "
Y
\n",
110 | "
None
\n",
111 | "
None
\n",
112 | "
1
\n",
113 | "
None
\n",
114 | "
115400
\n",
115 | "
...
\n",
116 | "
6111.0
\n",
117 | "
MICHIGAN AVE
\n",
118 | "
1
\n",
119 | "
None
\n",
120 | "
None
\n",
121 | "
6111.0
\n",
122 | "
MICHIGAN
\n",
123 | "
892049.5
\n",
124 | "
992992.3
\n",
125 | "
{'x': -90.24875893499996, 'y': 38.560418371000...
\n",
126 | "
\n",
127 | "
\n",
128 | "
1
\n",
129 | "
2
\n",
130 | "
16-056849
\n",
131 | "
2016-11
\n",
132 | "
2016-01-30 10:00:00
\n",
133 | "
Y
\n",
134 | "
None
\n",
135 | "
None
\n",
136 | "
1
\n",
137 | "
None
\n",
138 | "
65701
\n",
139 | "
...
\n",
140 | "
0.0
\n",
141 | "
HORNSBY AVE / NEWBY ST
\n",
142 | "
74
\n",
143 | "
None
\n",
144 | "
None
\n",
145 | "
992.0
\n",
146 | "
RIVERVIEW
\n",
147 | "
895706.0
\n",
148 | "
1050752.0
\n",
149 | "
{'x': -90.23538879799997, 'y': 38.718992161000...
\n",
150 | "
\n",
151 | "
\n",
152 | "
2
\n",
153 | "
3
\n",
154 | "
16-059816
\n",
155 | "
2016-11
\n",
156 | "
2016-02-03 00:01:00
\n",
157 | "
Y
\n",
158 | "
None
\n",
159 | "
None
\n",
160 | "
1
\n",
161 | "
None
\n",
162 | "
121000
\n",
163 | "
...
\n",
164 | "
3915.0
\n",
165 | "
OLIVE ST
\n",
166 | "
38
\n",
167 | "
None
\n",
168 | "
None
\n",
169 | "
3915.0
\n",
170 | "
OLIVE
\n",
171 | "
894624.9
\n",
172 | "
1022655.0
\n",
173 | "
{'x': -90.23945786399997, 'y': 38.641849847000...
\n",
174 | "
\n",
175 | "
\n",
176 | "
3
\n",
177 | "
4
\n",
178 | "
16-059170
\n",
179 | "
2016-11
\n",
180 | "
2011-02-04 00:01:00
\n",
181 | "
Y
\n",
182 | "
None
\n",
183 | "
None
\n",
184 | "
1
\n",
185 | "
None
\n",
186 | "
43025
\n",
187 | "
...
\n",
188 | "
3761.0
\n",
189 | "
MERAMEC ST
\n",
190 | "
16
\n",
191 | "
None
\n",
192 | "
None
\n",
193 | "
3756.0
\n",
194 | "
MERAMEC
\n",
195 | "
892275.9
\n",
196 | "
1001225.0
\n",
197 | "
{'x': -90.24788817199999, 'y': 38.583023065000...
\n",
198 | "
\n",
199 | "
\n",
200 | "
4
\n",
201 | "
5
\n",
202 | "
16-057345
\n",
203 | "
2016-11
\n",
204 | "
2010-03-07 00:01:00
\n",
205 | "
Y
\n",
206 | "
None
\n",
207 | "
None
\n",
208 | "
1
\n",
209 | "
None
\n",
210 | "
43026
\n",
211 | "
...
\n",
212 | "
3927.0
\n",
213 | "
CHIPPEWA ST
\n",
214 | "
15
\n",
215 | "
None
\n",
216 | "
None
\n",
217 | "
3927.0
\n",
218 | "
CHIPPEWA
\n",
219 | "
890901.7
\n",
220 | "
1003595.0
\n",
221 | "
{'x': -90.25267325099998, 'y': 38.589541155000...
\n",
222 | "
\n",
223 | " \n",
224 | "
\n",
225 | "
5 rows × 22 columns
\n",
226 | "
"
227 | ],
228 | "text/plain": [
229 | " OBJECTID Complaint CodedMonth DateOccur FlagCrime FlagUnfounded \\\n",
230 | "0 1 16-060225 2016-11 2013-01-01 09:37:00 Y None \n",
231 | "1 2 16-056849 2016-11 2016-01-30 10:00:00 Y None \n",
232 | "2 3 16-059816 2016-11 2016-02-03 00:01:00 Y None \n",
233 | "3 4 16-059170 2016-11 2011-02-04 00:01:00 Y None \n",
234 | "4 5 16-057345 2016-11 2010-03-07 00:01:00 Y None \n",
235 | "\n",
236 | " FlagAdministrative Count FlagCleanup Crime ... ILEADSAddress \\\n",
237 | "0 None 1 None 115400 ... 6111.0 \n",
238 | "1 None 1 None 65701 ... 0.0 \n",
239 | "2 None 1 None 121000 ... 3915.0 \n",
240 | "3 None 1 None 43025 ... 3761.0 \n",
241 | "4 None 1 None 43026 ... 3927.0 \n",
242 | "\n",
243 | " ILEADSStreet Neighborhood LocationName LocationComment \\\n",
244 | "0 MICHIGAN AVE 1 None None \n",
245 | "1 HORNSBY AVE / NEWBY ST 74 None None \n",
246 | "2 OLIVE ST 38 None None \n",
247 | "3 MERAMEC ST 16 None None \n",
248 | "4 CHIPPEWA ST 15 None None \n",
249 | "\n",
250 | " CADAddress CADStreet XCoord YCoord \\\n",
251 | "0 6111.0 MICHIGAN 892049.5 992992.3 \n",
252 | "1 992.0 RIVERVIEW 895706.0 1050752.0 \n",
253 | "2 3915.0 OLIVE 894624.9 1022655.0 \n",
254 | "3 3756.0 MERAMEC 892275.9 1001225.0 \n",
255 | "4 3927.0 CHIPPEWA 890901.7 1003595.0 \n",
256 | "\n",
257 | " SHAPE \n",
258 | "0 {'x': -90.24875893499996, 'y': 38.560418371000... \n",
259 | "1 {'x': -90.23538879799997, 'y': 38.718992161000... \n",
260 | "2 {'x': -90.23945786399997, 'y': 38.641849847000... \n",
261 | "3 {'x': -90.24788817199999, 'y': 38.583023065000... \n",
262 | "4 {'x': -90.25267325099998, 'y': 38.589541155000... \n",
263 | "\n",
264 | "[5 rows x 22 columns]"
265 | ]
266 | },
267 | "execution_count": 7,
268 | "metadata": {},
269 | "output_type": "execute_result"
270 | }
271 | ],
272 | "source": [
273 | "sdf.head()"
274 | ]
275 | },
276 | {
277 | "cell_type": "markdown",
278 | "metadata": {},
279 | "source": [
280 | "## Notice the Columns in the dataframe align with the attribute table of the feature class\n",
281 | "\n",
282 | "Show this in ArcGIS Pro."
283 | ]
284 | },
285 | {
286 | "cell_type": "markdown",
287 | "metadata": {},
288 | "source": [
289 | "## We can export this to a CSV file"
290 | ]
291 | },
292 | {
293 | "cell_type": "code",
294 | "execution_count": 9,
295 | "metadata": {},
296 | "outputs": [],
297 | "source": [
298 | "#change the name of this\n",
299 | "sdf.to_csv(path_or_buf=r\"test.csv\")"
300 | ]
301 | },
302 | {
303 | "cell_type": "markdown",
304 | "metadata": {},
305 | "source": []
306 | },
307 | {
308 | "cell_type": "markdown",
309 | "metadata": {},
310 | "source": [
311 | "## For this CSV to work with the webapp, the coordinates had to be in Latitude and Longitude. I had to convert that SHAPE JSON into Latitude and Longitude coordinates.\n",
312 | "\n",
313 | "This code effectively strips out the x and y values from the JSON and puts them into new pandas dataframe columns named Lon and Lat."
314 | ]
315 | },
316 | {
317 | "cell_type": "code",
318 | "execution_count": 34,
319 | "metadata": {},
320 | "outputs": [
321 | {
322 | "data": {
323 | "text/html": [
324 | "
\n",
325 | "\n",
338 | "
\n",
339 | " \n",
340 | "
\n",
341 | "
\n",
342 | "
OBJECTID
\n",
343 | "
Complaint
\n",
344 | "
CodedMonth
\n",
345 | "
DateOccur
\n",
346 | "
FlagCrime
\n",
347 | "
FlagUnfounded
\n",
348 | "
FlagAdministrative
\n",
349 | "
Count
\n",
350 | "
FlagCleanup
\n",
351 | "
Crime
\n",
352 | "
...
\n",
353 | "
Neighborhood
\n",
354 | "
LocationName
\n",
355 | "
LocationComment
\n",
356 | "
CADAddress
\n",
357 | "
CADStreet
\n",
358 | "
XCoord
\n",
359 | "
YCoord
\n",
360 | "
SHAPE
\n",
361 | "
Lon
\n",
362 | "
Lat
\n",
363 | "
\n",
364 | " \n",
365 | " \n",
366 | "
\n",
367 | "
0
\n",
368 | "
1
\n",
369 | "
16-060225
\n",
370 | "
2016-11
\n",
371 | "
2013-01-01 09:37:00
\n",
372 | "
Y
\n",
373 | "
None
\n",
374 | "
None
\n",
375 | "
1
\n",
376 | "
None
\n",
377 | "
115400
\n",
378 | "
...
\n",
379 | "
1
\n",
380 | "
None
\n",
381 | "
None
\n",
382 | "
6111.0
\n",
383 | "
MICHIGAN
\n",
384 | "
892049.5
\n",
385 | "
992992.3
\n",
386 | "
{'x': -90.24875893499996, 'y': 38.560418371000...
\n",
387 | "
-90.248759
\n",
388 | "
38.560418
\n",
389 | "
\n",
390 | "
\n",
391 | "
1
\n",
392 | "
2
\n",
393 | "
16-056849
\n",
394 | "
2016-11
\n",
395 | "
2016-01-30 10:00:00
\n",
396 | "
Y
\n",
397 | "
None
\n",
398 | "
None
\n",
399 | "
1
\n",
400 | "
None
\n",
401 | "
65701
\n",
402 | "
...
\n",
403 | "
74
\n",
404 | "
None
\n",
405 | "
None
\n",
406 | "
992.0
\n",
407 | "
RIVERVIEW
\n",
408 | "
895706.0
\n",
409 | "
1050752.0
\n",
410 | "
{'x': -90.23538879799997, 'y': 38.718992161000...
\n",
411 | "
-90.235389
\n",
412 | "
38.718992
\n",
413 | "
\n",
414 | "
\n",
415 | "
2
\n",
416 | "
3
\n",
417 | "
16-059816
\n",
418 | "
2016-11
\n",
419 | "
2016-02-03 00:01:00
\n",
420 | "
Y
\n",
421 | "
None
\n",
422 | "
None
\n",
423 | "
1
\n",
424 | "
None
\n",
425 | "
121000
\n",
426 | "
...
\n",
427 | "
38
\n",
428 | "
None
\n",
429 | "
None
\n",
430 | "
3915.0
\n",
431 | "
OLIVE
\n",
432 | "
894624.9
\n",
433 | "
1022655.0
\n",
434 | "
{'x': -90.23945786399997, 'y': 38.641849847000...
\n",
435 | "
-90.239458
\n",
436 | "
38.641850
\n",
437 | "
\n",
438 | "
\n",
439 | "
3
\n",
440 | "
4
\n",
441 | "
16-059170
\n",
442 | "
2016-11
\n",
443 | "
2011-02-04 00:01:00
\n",
444 | "
Y
\n",
445 | "
None
\n",
446 | "
None
\n",
447 | "
1
\n",
448 | "
None
\n",
449 | "
43025
\n",
450 | "
...
\n",
451 | "
16
\n",
452 | "
None
\n",
453 | "
None
\n",
454 | "
3756.0
\n",
455 | "
MERAMEC
\n",
456 | "
892275.9
\n",
457 | "
1001225.0
\n",
458 | "
{'x': -90.24788817199999, 'y': 38.583023065000...
\n",
459 | "
-90.247888
\n",
460 | "
38.583023
\n",
461 | "
\n",
462 | "
\n",
463 | "
4
\n",
464 | "
5
\n",
465 | "
16-057345
\n",
466 | "
2016-11
\n",
467 | "
2010-03-07 00:01:00
\n",
468 | "
Y
\n",
469 | "
None
\n",
470 | "
None
\n",
471 | "
1
\n",
472 | "
None
\n",
473 | "
43026
\n",
474 | "
...
\n",
475 | "
15
\n",
476 | "
None
\n",
477 | "
None
\n",
478 | "
3927.0
\n",
479 | "
CHIPPEWA
\n",
480 | "
890901.7
\n",
481 | "
1003595.0
\n",
482 | "
{'x': -90.25267325099998, 'y': 38.589541155000...
\n",
483 | "
-90.252673
\n",
484 | "
38.589541
\n",
485 | "
\n",
486 | " \n",
487 | "
\n",
488 | "
5 rows × 24 columns
\n",
489 | "
"
490 | ],
491 | "text/plain": [
492 | " OBJECTID Complaint CodedMonth DateOccur FlagCrime FlagUnfounded \\\n",
493 | "0 1 16-060225 2016-11 2013-01-01 09:37:00 Y None \n",
494 | "1 2 16-056849 2016-11 2016-01-30 10:00:00 Y None \n",
495 | "2 3 16-059816 2016-11 2016-02-03 00:01:00 Y None \n",
496 | "3 4 16-059170 2016-11 2011-02-04 00:01:00 Y None \n",
497 | "4 5 16-057345 2016-11 2010-03-07 00:01:00 Y None \n",
498 | "\n",
499 | " FlagAdministrative Count FlagCleanup Crime ... Neighborhood \\\n",
500 | "0 None 1 None 115400 ... 1 \n",
501 | "1 None 1 None 65701 ... 74 \n",
502 | "2 None 1 None 121000 ... 38 \n",
503 | "3 None 1 None 43025 ... 16 \n",
504 | "4 None 1 None 43026 ... 15 \n",
505 | "\n",
506 | " LocationName LocationComment CADAddress CADStreet XCoord YCoord \\\n",
507 | "0 None None 6111.0 MICHIGAN 892049.5 992992.3 \n",
508 | "1 None None 992.0 RIVERVIEW 895706.0 1050752.0 \n",
509 | "2 None None 3915.0 OLIVE 894624.9 1022655.0 \n",
510 | "3 None None 3756.0 MERAMEC 892275.9 1001225.0 \n",
511 | "4 None None 3927.0 CHIPPEWA 890901.7 1003595.0 \n",
512 | "\n",
513 | " SHAPE Lon Lat \n",
514 | "0 {'x': -90.24875893499996, 'y': 38.560418371000... -90.248759 38.560418 \n",
515 | "1 {'x': -90.23538879799997, 'y': 38.718992161000... -90.235389 38.718992 \n",
516 | "2 {'x': -90.23945786399997, 'y': 38.641849847000... -90.239458 38.641850 \n",
517 | "3 {'x': -90.24788817199999, 'y': 38.583023065000... -90.247888 38.583023 \n",
518 | "4 {'x': -90.25267325099998, 'y': 38.589541155000... -90.252673 38.589541 \n",
519 | "\n",
520 | "[5 rows x 24 columns]"
521 | ]
522 | },
523 | "execution_count": 34,
524 | "metadata": {},
525 | "output_type": "execute_result"
526 | }
527 | ],
528 | "source": [
529 | "#x = []\n",
530 | "#y = []\n",
531 | "for idx,val in enumerate(sdf.iterrows()):\n",
532 | " #print(val[1].SHAPE)\n",
533 | " j = val[1].SHAPE\n",
534 | " #x.append(j['x'])\n",
535 | " #y.append(j['y'])\n",
536 | " sdf.loc[idx,'Lon'] = j['x']\n",
537 | " sdf.loc[idx,'Lat'] = j['y']\n",
538 | " \n",
539 | "#sdf['Lon'] = x\n",
540 | "#sdf['Lat'] = y\n",
541 | "sdf.head()"
542 | ]
543 | },
544 | {
545 | "cell_type": "code",
546 | "execution_count": null,
547 | "metadata": {},
548 | "outputs": [],
549 | "source": []
550 | },
551 | {
552 | "cell_type": "markdown",
553 | "metadata": {},
554 | "source": [
555 | "## Now I can save that dataframe to a CSV with a subset of fields"
556 | ]
557 | },
558 | {
559 | "cell_type": "code",
560 | "execution_count": 35,
561 | "metadata": {},
562 | "outputs": [],
563 | "source": [
564 | "sdf.to_csv(\n",
565 | " path_or_buf=r\"stl_crime_wgs_84_10282018.csv\", \n",
566 | " columns=['Crime', 'District', 'Neighborhood', 'ILEADSStreet', 'CADStreet', 'Lon', 'Lat']\n",
567 | ")"
568 | ]
569 | },
570 | {
571 | "cell_type": "markdown",
572 | "metadata": {},
573 | "source": [
574 | "## This is cool, but..."
575 | ]
576 | },
577 | {
578 | "cell_type": "code",
579 | "execution_count": null,
580 | "metadata": {},
581 | "outputs": [],
582 | "source": []
583 | }
584 | ],
585 | "metadata": {
586 | "kernelspec": {
587 | "display_name": "Python 3",
588 | "language": "python",
589 | "name": "python3"
590 | },
591 | "language_info": {
592 | "codemirror_mode": {
593 | "name": "ipython",
594 | "version": 3
595 | },
596 | "file_extension": ".py",
597 | "mimetype": "text/x-python",
598 | "name": "python",
599 | "nbconvert_exporter": "python",
600 | "pygments_lexer": "ipython3",
601 | "version": "3.6.9"
602 | }
603 | },
604 | "nbformat": 4,
605 | "nbformat_minor": 2
606 | }
607 |
--------------------------------------------------------------------------------
/Unit 12/README.md:
--------------------------------------------------------------------------------
1 | # This week's notebooks
2 | This week's lecture notebooks are in ArcGIS Online at
3 | [GIS 4090\5090 Unit 12 Notebooks](https://slustl.maps.arcgis.com/home/group.html?id=87bd11b5636a470db344bb2cc6bb03ef#overview)
4 |
5 | You can also find older versions of these notebooks here:
6 |
7 | File Lecture 4 - plotting_with_plotly.ipynb Click for more options (3.502 MB)
8 | File matplotlib_styles.ipynb Click for more options (1.509 KB)
9 | File Lecture 1 - Matplotlib.ipynb Click for more options (71.808 KB)
10 | File Lecture 2 - Intro to Spatial Dataframes (Feature to CSV in Lat and Longitude).ipynb Click for more options (19.769 KB)
11 | File Lecture 3 - CSV to Spatial DataFrame to GIS Data.ipynb Click for more options (64.365 KB)
12 |
13 | # Data for lectures
14 | The following CSV and GDB are used for the lecture demos:
15 |
16 | File SENZA_0_SUNAA_0_CORN.xlsx Click for more options (426.275 KB)
17 | File crime_data.gdb.zip Click for more options (639.273 KB)
18 |
19 | # Potting Resources
20 | These are resources from the [Python Data Science Handbook](https://jakevdp.github.io/PythonDataScienceHandbook/):
21 | - [Matplotlib](https://jakevdp.github.io/PythonDataScienceHandbook/04.00-introduction-to-matplotlib.html)
22 | - [Line Plots](https://jakevdp.github.io/PythonDataScienceHandbook/04.01-simple-line-plots.html)
23 | - [Scatter Plots](https://jakevdp.github.io/PythonDataScienceHandbook/04.02-simple-scatter-plots.html)
24 |
25 | # Homework
26 | ## Final Project Status Update
27 | In this discussion forum, please give the class an update on where you are
28 | with your final project. Please include a paragraph that summarize your
29 | status. Feel free to share any links, data, screen shots, or notebooks
30 | that you are willing to share or looking for feedback on.
31 |
32 | Please comment on two of your classmate posts.
33 |
34 | Start by clicking "Create Thread".
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Unit 12/SENZA_0_SUNAA_0_CORN.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 12/SENZA_0_SUNAA_0_CORN.xlsx
--------------------------------------------------------------------------------
/Unit 12/crime_data.gdb.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbrunner/programming-for-gis-and-rs/e623312548ca5807730f37e625a304ca93e6c36e/Unit 12/crime_data.gdb.zip
--------------------------------------------------------------------------------
/Unit 12/matplotlib_styles.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# https://matplotlib.org/tutorials/introductory/customizing.html"
8 | ]
9 | },
10 | {
11 | "cell_type": "code",
12 | "execution_count": 2,
13 | "metadata": {},
14 | "outputs": [],
15 | "source": [
16 | "from matplotlib import pyplot as plt"
17 | ]
18 | },
19 | {
20 | "cell_type": "code",
21 | "execution_count": 3,
22 | "metadata": {},
23 | "outputs": [
24 | {
25 | "name": "stdout",
26 | "output_type": "stream",
27 | "text": [
28 | "['bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark-palette', 'seaborn-dark', 'seaborn-darkgrid', 'seaborn-deep', 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 'seaborn-pastel', 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'seaborn-whitegrid', 'seaborn', 'Solarize_Light2', 'tableau-colorblind10', '_classic_test']\n"
29 | ]
30 | }
31 | ],
32 | "source": [
33 | "print(plt.style.available)"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "metadata": {},
40 | "outputs": [],
41 | "source": []
42 | }
43 | ],
44 | "metadata": {
45 | "kernelspec": {
46 | "display_name": "Python 3",
47 | "language": "python",
48 | "name": "python3"
49 | },
50 | "language_info": {
51 | "codemirror_mode": {
52 | "name": "ipython",
53 | "version": 3
54 | },
55 | "file_extension": ".py",
56 | "mimetype": "text/x-python",
57 | "name": "python",
58 | "nbconvert_exporter": "python",
59 | "pygments_lexer": "ipython3",
60 | "version": "3.6.9"
61 | }
62 | },
63 | "nbformat": 4,
64 | "nbformat_minor": 4
65 | }
66 |
--------------------------------------------------------------------------------
/Unit 13/README.md:
--------------------------------------------------------------------------------
1 | # Watch this video
2 | [ArcGIS API for JavaScript: Getting Started](https://www.youtube.com/watch?v=pYHWoSNsSIU)
3 |
4 | # Check out ArcGIS JSAPI Samples
5 | [ArcGIS API for JavaScript Sample Code](https://developers.arcgis.com/javascript/latest/sample-code/)
6 |
7 | # Learn JS using Esri Hackerlabs
8 | These have not been updated in three or four years, but they used to be awesome. [Check out
9 | the hackerlabs](https://github.com/Esri/geodev-hackerlabs)
10 |
11 | # CodePen.io
12 | If you continue with the Advanced course next semester, you will learn JavaScript.
13 | We will use [CodePen.io](https://codepen.io/) as a tool to write and test code.
14 |
15 | # Web Mapping Development Intro
16 |
17 | Jacob Wasilkowski
18 |
19 | [Twitter @JWasilGeo](https://twitter.com/JWasilGeo)
20 |
21 | [https://jwasilgeo.github.io](https://jwasilgeo.github.io)
22 |
23 | ## Intro to HTML, CSS, and JavaScript
24 |
25 | What's the purpose of each and how do they work together?
26 |
27 | READ :clap: THE :clap: DOCS :clap:
28 |
29 | [https://developer.mozilla.org/en-US/docs/Web](https://developer.mozilla.org/en-US/docs/Web)
30 |
31 | ## JavaScript: syntax intro
32 |
33 | ```javascript
34 | // variable declaration
35 | let myString;
36 |
37 | // and then later assignment
38 | myString = 'sample string';
39 |
40 | // variable declaration and assignment at same time
41 | let myNumber = 90210;
42 |
43 | console.log(myNumber - 90209); // simple math
44 |
45 | // strings
46 | let question = 'Is pizza awesome?';
47 | let answer = 'Without a doubt.';
48 | let qAndA = question + ' ' + answer; // concatenate strings
49 |
50 | console.log(qAndA);
51 |
52 | // format with template strings
53 | console.log(`${question} ${answer}`);
54 |
55 | // booleans
56 | console.log(1.5 === 1.5); // true
57 | console.log(1 + 1 === 3); // false
58 |
59 | // arrays
60 | let myArray = [1, 2, 3, 'x', 'y', 'z'];
61 |
62 | console.log(myArray[3]);
63 |
64 | myArray.push(100);
65 |
66 | let stringFromArray = myArray.join(' and ');
67 |
68 | console.log(stringFromArray);
69 |
70 | // functions
71 | let sumThreeNumbers = function(a, b, c) {
72 | // do something with the function arguments
73 | console.log(a, b, c);
74 | // return the sum
75 | return a + b + c;
76 | };
77 |
78 | // objects
79 | let myObject = {
80 | name: 'Greg',
81 | totalCats: 15,
82 | faveLanguages: ['Python', 'JavaScript'],
83 | isInCharge: true,
84 | tellMeSomethingInteresting: function() {
85 | return this.name + ' has ' + this.totalCats + ' cats.'
86 | }
87 | };
88 |
89 | console.log(myObject.name);
90 |
91 | console.log(myObject.tellMeSomethingInteresting());
92 |
93 | // conditional statements
94 | let whatHappened;
95 | if (1 === 2) {
96 | whatHappened = 'bad math';
97 | } else if (true && false) {
98 | whatHappened = 'bad logic';
99 | } else {
100 | whatHappened = 'we got to the "else!"';
101 | }
102 | console.log(whatHappened);
103 | ```
104 |
105 | **Start thinking in terms of user interaction _"events"_ instead of top-to-bottom script execution.**
106 |
107 | Obligatory JS meme
108 |
109 | 
110 |
111 | ## HTML and CSS and JavaScript
112 |
113 | **Exercise:** create `index.html` page, insert `
204 |