# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [default]
#     language: python
#     name: python3
# ---

# + [markdown] slideshow={"slide_type": "slide"}
# # Scripting and Automation for the Web GIS Power User

# + [markdown] slideshow={"slide_type": "slide"}
# ## Reasons
#  1. Prototpying ideas
#  2. Integration with Pandas and plotting libraries
#  3. Integration with ArcGIS
#  4. Growing open-source project with [numeours extensions](http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/)

# + [markdown] slideshow={"slide_type": "subslide"}
# ### 1. Prototyping ideas
# <img src="prototype_analysis.png" height="500" width="500">

# + [markdown] slideshow={"slide_type": "subslide"}
# ### 2. Integration with pandas and plotting libraries

# + slideshow={"slide_type": "fragment"}
# read and display a csv file
import pandas as pd
csv = pd.read_csv('major_earthquakes.csv')
csv.head()

# + slideshow={"slide_type": "fragment"}
import matplotlib.pyplot as plt
# %matplotlib inline
csv.hist('DamageExtent')

# + [markdown] slideshow={"slide_type": "subslide"}
# ### 3. Integration with ArcGIS

# + slideshow={"slide_type": "fragment"}
from arcgis.gis import *
gis = GIS()
m1 = gis.map()
m1

# + slideshow={"slide_type": "fragment"}
eq = gis.content.search("earthquakes", "feature layer")[0]
m1.add_layer(eq)

# + [markdown] slideshow={"slide_type": "subslide"}
# ### 4. Growing open source project, lots of extensions
#  1. Collapsible headings
#  2. RISE - presentations
#  3. [list of extensions](http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/)
# -

# ## How to get notebooks on your computer?
#  1. Through ArcGIS Pro
#  2. Install conda
#  3. Try the live notebooks

# + [markdown] slideshow={"slide_type": "slide"}
# ## How to use notebooks and best practices

# + [markdown] slideshow={"slide_type": "subslide"}
# ### Notebooks walk through
#  1. Cell types - markdown, code
#  2. Running cells
#  3. Using intellisense
#  4. REPL - read evaluate print loop

# + [markdown] slideshow={"slide_type": "subslide"}
# Markdown - headings
# # H1
# ## H2
# ### H3
# #### H4

# + [markdown] slideshow={"slide_type": "fragment"}
# Markdown - bold, italics, code snippet
#
# **this is bold**
#
# _this is italics_ and this is not
# -

# embed images
# ![](http://mms.businesswire.com/media/20170615005128/en/570118/4/esri_logo17.jpg)

# + [markdown] slideshow={"slide_type": "subslide"}
# ### singe line code highlighting
# Represent equation of a straight line: `y = m*x + C`

# + [markdown] slideshow={"slide_type": "fragment"}
# ### multiline code highlighting
# ```PYTHON
# import os
# data_root = r'root dir to walk down'
# for directory, subdir_list, file_list in os.walk(data_root):
#     print(directory)
#     print("\t", end="")
#     print(subdir_list)
#     print("\t\t", end="")
#     print(file_list)
# ```

# + slideshow={"slide_type": "subslide"}
#this is a code cell
1+2

# run this by hitting `shift + enter`

# + slideshow={"slide_type": "fragment"}
# code cell
import sys
sys.version

# + slideshow={"slide_type": "subslide"}
# fixing errors - intellisense
sys.pth

# + [markdown] slideshow={"slide_type": "subslide"}
# #### Using intellisense - Python API

# + slideshow={"slide_type": "fragment"}
from arcgis.gis import *
gis = GIS()

# + slideshow={"slide_type": "fragment"}
#look for the basemaps groups in arcgis online
#use intellisense - dot notation
gis.


# + slideshow={"slide_type": "subslide"}
#build a query - look up method parameters, pull up help into new page
# gis.groups.search?

# + slideshow={"slide_type": "fragment"}
#REPL
groups_list = gis.groups.search("basemaps")
groups_list

# + [markdown] slideshow={"slide_type": "slide"}
# ### Notebooks - best practices
#  1. Don't pull all your code in 1 cell
#  2. Add documentation
#  3. Use password hiders
#  4. Share notebooks on github

# + slideshow={"slide_type": "subslide"}
import getpass
password = <PASSWORD>()
ago_gis = GIS("https://python.playground.esri.com/portal", "atma.mani", password)

# + slideshow={"slide_type": "subslide"}
from arcgis.gis import GIS
ago_gis = GIS("https://python.playground.esri.com/portal", "atma.mani")

# + slideshow={"slide_type": "fragment"}
ago_gis
# -

# ## Reproducible research

# ### Sharing notebooks

StarcoderdataJupyterScriptsDedupFiltered