1 / 28

Why python?

What is python?. Scripting programming language Similar to models but text based Design emphasized code readability. Why python?. Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management.

floyd
Télécharger la présentation

Why python?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What is python? Scripting programming language Similar to models but text based Design emphasized code readability Why python? Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management

  2. Three step process to integrate python into your GIS projects. . . Create model outline in ModelBuilder Customize model in an Python editor, such as PythonWin or IDLE Import script into a ToolBox in ArcCatalog

  3. Create a file management model using ModelBuilder Script for easy data management includes: Main folder: Name of folder determined by user Subfolders: Data, MXD, Images, Other Sub-Subfolder: Working Data Geodatabase: Output Geodatabase and Feature Dataset

  4. Export as a python script

  5. Edit script in an editor (I used IDLE) Add descriptions Import necessary modules Change variables to get parameters. Make necessary changes to actual script to match changes

  6. Added descriptions Imported Modules Set Parameters and local variables Run and correct necessary errors

  7. Swiss Hillshade Process for Multiple Rasters

  8. Create a swiss hillshade model using model builder

  9. Export to script

  10. Open script in an editing program (IDLE or Pythonwin)

  11. Import necessary modules

  12. And check out extensions

  13. Designate the workspace containing rasters for processing Get Parameter As Text allows the input to be entered as a parameter of the tool

  14. Enable overwriting of output

  15. Make a list of all the rasters in the workspace The list is created and stored as rasterList but not displayed “GRID” specifies the raster type

  16. Create a “for” loop to run the model for each raster Everything indented under this command is performed for every raster in the folder

  17. Create a new folder name for each iteration The folder name that stores the output rasters will be “swiss_hs” followed by the name of the input raster

  18. Create the folder under a variable

  19. Determine which variables are to be dynamic Inputs Outputs Azimuth Z Factor

  20. Assign the dynamic inputs to the variables “raster” = the raster in the folder Output folder (created above) and the new raster name

  21. Change the process parameters to match the variables *Note: The following code is used for the raster calculation rather than the one that is exported from modelbuilder

  22. Copy and paste the processing code and change parameter variables Updating the variables as needed Repeat if desired

  23. Enter a print statement to say what folder the new rasters are in

  24. Load the script into an ArcGIS toolbox

  25. Name the script

  26. Select the script

  27. Enter the inputs from the script and their type

  28. The script can now be run from an ArcGIS Toolbox

More Related