Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GEOG 315, Lecture 5

alan.kasprak
September 21, 2021

GEOG 315, Lecture 5

alan.kasprak

September 21, 2021
Tweet

More Decks by alan.kasprak

Other Decks in Education

Transcript

  1. GEOG 315: GIS Programming and Web Mapping Lecture 5 –

    Geoprocessing, finally For Today… 1. Some housekeeping 2. Geoprocessing, done three ways: 2a. With ArcMap/ArcPro Dialogs 2b. With Modelbuilder 2c. With Python
  2. Some Items to Review… The things that are in a

    for loop get done every time through that loop. …so think carefully about what’s in the loop and what’s not!
  3. For Loops [for every item in a list, do something

    to that item] here’s a plate, two glasses, a salad bowl, a spatula, a knife, three forks, a cutting board, six spoons, and a crock pot
  4. For Loops [for every item in a list, do something

    to that item] here’s a plate, two glasses, a salad bowl, a spatula, a knife, three forks, a cutting board, six spoons, and a crock pot Make soapy water for each dish in the list of dishes: wash dish with sponge rinse with hot water place in drying rack
  5. For Loops [for every item in a list, do something

    to that item] for each dish in the list of dishes: make soapy water wash dish with sponge rinse with hot water place in drying rack make soapy water for each dish in the list of dishes: wash dish with sponge rinse with hot water place in drying rack
  6. For Loops [for every item in a list, do something

    to that item] for each dish in the list of dishes: make soapy water wash dish with sponge rinse with hot water place in drying rack Make soapy water for each dish in the list of dishes: wash dish with sponge rinse with hot water place in drying rack This one is efficient This one takes forever
  7. Some Items to Review… The things that are in a

    for loop get done every time through that loop. …so think carefully about what’s in the loop at what’s not! How can we tell what’s in this loop?
  8. Some Items to Review… The things that are in a

    for loop get done every time through that loop. …so think carefully about what’s in the loop at what’s not! How can we tell what’s in this loop?
  9. Some Items to Review… The things that are in a

    for loop get done every time through that loop.
  10. Some Items to Review… The things that are in a

    for loop get done every time through that loop.
  11. Some Items to Review… The things that are in a

    for loop get done every time through that loop.
  12. Some Items to Review… You don’t need to turn in

    code that produces errors/the wrong output!
  13. Some Items to Review… You don’t need to turn in

    code that produces errors/the wrong output!
  14. Some Items to Review… You don’t need to turn in

    code that produces errors/the wrong output*! *Unless you’re unable to get the answer! Then turn in what you’ve got (and comment it) so I can give partial credit
  15. GEOG 315: GIS Programming and Web Mapping Lecture 5 –

    Geoprocessing, finally For Today… 1. Some housekeeping 2. Geoprocessing, done three ways: 2a. With ArcMap/ArcPro Dialogs 2b. With Modelbuilder 2c. With Python
  16. 2. Geoprocessing, done three ways: 2a. With ArcMap/ArcPro Dialogs REQUIRED

    INPUTS This tool takes 7 inputs 3 are required 4 are optional *
  17. 2. Geoprocessing, done three ways: 2a. With ArcMap/ArcPro Dialogs REQUIRED

    INPUTS This tool takes 7 inputs 3 are required 4 are optional
  18. 2. Geoprocessing, done three ways: 2a. With ArcMap/ArcPro Dialogs This

    is great – but in reality I… 1.downloaded the elevation data from the USGS 2.reprojected it from lat/long to meters (project raster) 3.hillshaded it (hillshade) 4.contoured it (contour)
  19. 2. Geoprocessing, done three ways: 2a. With ArcMap/ArcPro Dialogs If

    I wanted to do this for ten (or 20, 100, 200) DEMs, it would get old quickly, and so would I.
  20. 2. Geoprocessing, done three ways: 2a. With ArcMap/ArcPro Dialogs Batch

    Processing can help with this, but only for one tool at a time.
  21. 2. Geoprocessing, done three ways: 2b. With Model Builder I

    specify input and output dataset names and “link” tools together to form a workflow
  22. 2. Geoprocessing, done three ways: 2b. With Model Builder Modelbuilder

    exists in ArcPro. It’s a bit clunky. But Model Builder still requires that we tell it every input filename, intermediate filename, and output filename!
  23. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy You can

    access Python from both ArcMap and ArcPro
  24. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Python shell

    in ArcMap and Pro Pro also has Jupyter! …but it’s easier to save notebooks using regular Jupyter
  25. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Let’s look

    at the contour tool more closely. Anybody ever click this button?
  26. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy “PYTHON WINDOW”

    “STAND-ALONE SCRIPT” What’s the difference? You can run #1 in the PYTHON WINDOW You can run #2 in JUPYTER
  27. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy This will

    run in ArcMap/Pro if you have the Python Window open
  28. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy This will

    run in Jupyter AND MORE IMPORTANTLY You can send this script to anyone with ArcMap/Pro and they can run it too.
  29. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Let’s talk

    about what’s going on here – and you’ll try this in lab. import arcpy #import the arcpy module #just like math, datetime, random
  30. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Let’s talk

    about what’s going on here – and you’ll try this in lab. from arcpy import env #bring in the environments module from arcpy, which lets us tell arcpy where our files are on the computer
  31. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Let’s talk

    about what’s going on here – and you’ll try this in lab. from arcpy.sa import * # import all the tools (*) # from spatial analyst toolbox
  32. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Let’s talk

    about what’s going on here – and you’ll try this in lab. env.workspace = “C:/sapyexamples/data” # define the workspace (aka ‘environment’) where # we’re going to read/write files
  33. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Let’s talk

    about what’s going on here – and you’ll try this in lab. Contour(“elevation”, “C:/sapyexamples/output/outcontours.shp, 200,0) # function(in_raster,out_polyline_features, # contour_interval, base_contour)
  34. 2. Geoprocessing, done three ways: 2c. With Python/ArcPy Let’s talk

    about what’s going on here – and you’ll try this in lab. Contour(“elevation”, “C:/sapyexamples/output/outcontours.shp, 200,0) # run the contour function on “elevation”, output the # result to “outcontours.shp, use a contour interval of # 200, and a base contour of 0
  35. Lab this week will look a little different. You’ll work

    through an exercise 1. Geoprocessing with dialog box tools 2. Geoprocessing with model builder 3. Geoprocessing with the Python window You’ll run more Python geoprocessing in homework 1. Geoprocessing using Jupyter notebooks A single .zip folder with three screenshots (in the Jupyter assignment) A single .zip folder with a Jupyter notebook (in the homework assignment)