+ All Categories
Home > Documents > Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for...

Python: An Introduction - Esri · 2017-02-22 · Python Script 1: Combines and reformats tables for...

Date post: 20-May-2020
Category:
Upload: others
View: 12 times
Download: 0 times
Share this document with a friend
39
Python: An Introduction Brittney White, Esri Katie Leaverton, Chesapeake Bay Foundation
Transcript
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Model

Python and Model Builder

Page 35: 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

Resources

http://esriurl.com/FedGISIntroPython

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

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

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

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

Recommended