Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for...
Transcript of Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for...
![Page 1: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/1.jpg)
Python: An IntroductionBrittney White, Esri
Katie Leaverton, Chesapeake Bay Foundation
![Page 2: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/2.jpg)
![Page 3: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/3.jpg)
What is Python?
• Simple and easy to learn
• Free and open source
• Cross platform
• Scripting language of ArcGIS
![Page 4: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/4.jpg)
Why use Python and ArcGIS?
• Automate repetitive tasks
- Data management
- Spatial analysis
- Map automation
• Make your own geoprocessing tools
![Page 5: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/5.jpg)
What is ArcPy?
• Access point to ArcGIS functionality
through Python
1. Geoprocessing tools
2. Functions like ListFeatureClasses,
Describe
3. Classes like Polygon,
SpatialReference
4. Modules
![Page 6: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/6.jpg)
Where do I write Python code?
• IDE
- PyCharm, Spyder, Wing IDE, Python IDLE,…
• Python window in ArcGIS
![Page 7: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/7.jpg)
Demo: Python
Window
![Page 8: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/8.jpg)
Goal
• List the shapefiles in folder
• Check the coordinate system of
each shapefile
• Project the shapefiles into NAD
1983 State Plane Maryland FIPS
1900 coordinate system
• Migrate shapefiles into a project file
geodatabase
![Page 9: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/9.jpg)
Demo: Prepare
shapefiles for
analysis
![Page 10: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/10.jpg)
Using GIS and Python to Save Time and Save the Bay
![Page 11: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/11.jpg)
![Page 12: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/12.jpg)
![Page 13: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/13.jpg)
Reporting RequirementsProgram: Baltimore Harbor Study Center
Vessels: Snowgoose
General Locations: Fort Carroll, Port of Baltimore, Patapsco River, Baltimore Chesapeake Bay
Collection Methods Used: Otter trawls and oyster hand scrapes
SPECIES NAME MARCH APRIL MAY JUNE JULY AUG SEPT OCT NOV DEC TOTAL
Alewife
American Eel
American Shad
Atlantic Menhaden
Bay Anchovy
Black Crappie
Black Drum
Black Sea Bass
Blenny
Blue Crab
Blue Crab(bushels)
Blue Fish
Blueback Herring
Bluegill
Bullhead
Butterfish
Carp
![Page 14: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/14.jpg)
Old Process
• Write in field notebook
• Add to spreadsheet
• Send to Education Operations Coordinator
• Combine spreadsheets and summarize for reporting
![Page 15: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/15.jpg)
Old Process
• Inaccurate
• Time consuming
• Inefficient
• Provided limited use of the data
Problems
![Page 16: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/16.jpg)
Goals
1. Collect species data in field across programs accurately
2. Automate the data processing for reporting
3. Provide the data back to the educators in a useful way
![Page 17: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/17.jpg)
The Platform
• SQL Server
• ArcGIS Desktop
• ArcGIS Server
• ArcGIS Online
• Collector for ArcGIS
• Python
• Model Builder
• Web app Builder
Our Solution
![Page 18: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/18.jpg)
Step 1: Designing the SQL Server Database
• SQL server database
• 2 related tables (Samples and Species) with a one to many relationship
• Published to ArcGIS Server and shared through ArcGIS Online
SQL Server and ArcMap
![Page 19: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/19.jpg)
Step 1: Designing the SQL Server Database
• SQL server database
• 2 related tables (Samples and Species) with a one to many relationship
• Published to ArcGIS Server and shared through ArcGIS Online
SQL Server and ArcMap
![Page 20: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/20.jpg)
Step 2: Publish Tables and Collect Data
ArcGIS Server, ArcGIS Online, and Collector
![Page 21: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/21.jpg)
Goals
1. Collect species data in field across programs accurately
2. Automate the data processing for reporting
3. Provide the data back to the educators in a useful way
![Page 22: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/22.jpg)
Step 3: Automate Reporting
Python and Model Builder
![Page 23: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/23.jpg)
Python Script 1: Combines and reformats tables for reporting1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
Python and Model Builder
![Page 24: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/24.jpg)
Python Script 1: Combines and reformats tables for reporting1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
Python and Model Builder
![Page 25: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/25.jpg)
Python Script 1: Combines and reformats tables for reporting
Python and Model Builder
1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
![Page 26: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/26.jpg)
Python Script 1: Combines and reformats tables for reporting1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
Python and Model Builder
![Page 27: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/27.jpg)
Python Script 1: Combines and reformats tables for reporting1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
Python and Model Builder
![Page 28: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/28.jpg)
Python Script 1: Combines and reformats tables for reporting1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
Python and Model Builder
![Page 29: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/29.jpg)
Python Script 1: Combines and reformats tables for reporting1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
Python and Model Builder
![Page 30: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/30.jpg)
Python Script 1: Combines and reformats tables for reporting1. Populate fields for month and year
2. Join the sample table to the species table
3. Pivot the table
4. Add fields for missing months
5. Summarize the total number of each species caught by month, year, and program
6. Calculate Simpsons Diversity Index
7. Create feature class showing where each species is collected
Python and Model Builder
![Page 31: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/31.jpg)
Python and Model Builder
![Page 32: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/32.jpg)
Python Script 2: Get header information
Program: Baltimore Harbor Study Center
Vessels: Snowgoose
General Locations: Fort Carroll, Port of Baltimore, Patapsco River, Baltimore Chesapeake Bay
Collection Methods Used: Otter trawls and oyster hand scrapes
SPECIES NAME MARCH APRIL MAY JUNE JULY AUG SEPT OCT NOV DEC TOTAL
Alewife
American Eel
American Shad
Atlantic Menhaden
Bay Anchovy
Black Crappie
Black Drum
Black Sea Bass
Blenny
Blue Crab
Blue Crab(bushels)
Blue Fish
Blueback Herring
Bluegill
Bullhead
Butterfish
Python and Model Builder
![Page 33: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/33.jpg)
Model
Python and Model Builder
![Page 34: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/34.jpg)
Web Application
![Page 36: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/36.jpg)
Additional Python Sessions
• Python: Beyond the Basics (146 B)
- Tuesday 2:45pm
• Python: Building Geoprocessing Tools (146 B)
- Tuesday 4:00pm
• Advanced Map Automation with Python (146 B)
- Tuesday 5:15pm
![Page 37: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/37.jpg)
Please Take Our Survey on the Esri Events App!
Select the session
you attended
Scroll down to find
the survey
Complete Answers
and Select “Submit”
Download the Esri Events
app and find your event
![Page 38: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/38.jpg)
Print Your Certificate of Attendance
Print stations located in the 140 Concourse
Monday
12:30 PM – 6:30 PM
GIS Solutions Expo,
Hall B
5:15 PM– 6:30 PM
Expo Social,
Hall B
Tuesday
10:45 AM– 5:15 PM
GIS Solutions Expo,
Hall B
6:30 PM– 9:30 PM
Networking Reception,
Smithsonian National Air
and Space Museum
![Page 39: Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for reporting Python and Model Builder 1. Populate fields for month and year 2. Join](https://reader031.fdocuments.in/reader031/viewer/2022013021/5ec4611c6e1c8301a2247be2/html5/thumbnails/39.jpg)