{"id":88,"date":"2021-09-26T23:23:52","date_gmt":"2021-09-27T04:23:52","guid":{"rendered":"https:\/\/sites.owu.edu\/geog-199\/?p=88"},"modified":"2021-11-01T22:32:42","modified_gmt":"2021-11-02T03:32:42","slug":"mcconkey-chapter-5","status":"publish","type":"post","link":"https:\/\/sites.owu.edu\/geog-293\/2021\/09\/26\/mcconkey-chapter-5\/","title":{"rendered":"McConkey: Chapter 5"},"content":{"rendered":"<p><span style=\"font-weight: 400\">This chapter was alright compared to the others but there are definitely a few concepts I do not quite understand yet. <\/span><\/p>\n<p><span style=\"font-weight: 400\">ArcPy is built into ArcGIS Pro if you are using IDLE. Other IDE\u2019s like Spyder requires extra steps to access ArcPY.\u00a0<\/span><\/p>\n<p><strong>Key Terms:<\/strong><\/p>\n<p><span style=\"font-weight: 400\">Class- are used to create objects which have properties and methods<\/span><\/p>\n<p><span style=\"font-weight: 400\">Environment- Hidden parameters that influence how a tool is run<\/span><\/p>\n<p><span style=\"font-weight: 400\">Hard-coded- the parameters are not set as variables but use the values assigned to them directly.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Namespace- a system to make sure all the names are unique and can be used without any conflicts<\/span><\/p>\n<p><span style=\"font-weight: 400\">nontool function- A function in Python performs a specific task. ArcPy provides several functions that are not tools, otherwise known as nontool functions. Nearly all\u00a0 geoprocessing tools in ArcGIS Pro or functions in ArcPy, but not all ArcPy functions are geoprocessing tools in ArcGIS Pro.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Package- a collection of modules, functions, and classes that adds functionality to Python<\/span><\/p>\n<p><span style=\"font-weight: 400\">Property- a workspace is an example of a property that an object has<\/span><\/p>\n<p><span style=\"font-weight: 400\">toolbox alias- tools may share the same tool name so they require a specific tool alias when applied in ArcPy (ex. Clip_management)<\/span><\/p>\n<p><span style=\"font-weight: 400\">tool label- a tool name with no spaces (ex. AddField [as in ArcPy])<\/span><\/p>\n<p><span style=\"font-weight: 400\">tool name- a tool label that contains spaces (ex. Add Field [in Data Management toolbox])<\/span><\/p>\n<p><span style=\"font-weight: 400\">factory code (of a coordinate system)\/well-known ID (WKID)- A series of numbers used to represent a name. WKIDs are often used for map projections because their names can be written out in different ways but not always be recognized by Python.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Workspace- provides a default location for the files you will be working with, such as inputs and outputs of geoprocessing tools.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0<\/span><\/p>\n<p><strong>Review Questions:<\/strong><\/p>\n<p><strong>Explain the relationship between the geoprocessing tools in ArcGIS Pro and the functions in ArcPy?<\/strong><\/p>\n<p><span style=\"font-weight: 400\">ArcPy must be imported first in order to use its geoprocessing tools. ArcPy makes Python scripting easier and more powerful.\u00a0<\/span><\/p>\n<p><strong>What exactly is the difference between required and optional parameters of geoprocessing tools, and how does this impact writing code to use these tools in a script?<\/strong><\/p>\n<p><span style=\"font-weight: 400\">Required and optional parameters are just as they sound. Required parameters are required for the script to run properly while optional parameters are not. There are a variety of ways to write the optional parameters in your script without them actually doing anything. This can be done by writing \u201c\u201d, \u201c#\u201d, or None in its place. This will leave the optional parameters at their default values.<\/span><\/p>\n<p><strong>Give an example of the use of variables for parameters instead of hard-coding values to make your code more versatile?<\/strong><\/p>\n<p><span style=\"font-weight: 400\">You could write as follows:<\/span><\/p>\n<p><span style=\"font-weight: 400\">import arcpy<\/span><\/p>\n<p><span style=\"font-weight: 400\">arcpy.env.workspace = \u201cC:\/Data\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">infc = \u201cstreams.shp\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">clipfc = \u201cstudy.shp\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">outfc = \u201cresults.sph\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">arcpy.Clip_analysis(infc, clipfc, outfc)<\/span><\/p>\n<p><span style=\"font-weight: 400\">If you are writing scripts or tools to be shared with others it is wise to use variables instead of hard-coding. Variables also make it easier to reuse part of your code.<\/span><\/p>\n<p><strong>Explain some of the uses of the \u201cResult\u201d object:\u00a0<\/strong><\/p>\n<p><span style=\"font-weight: 400\">ArcPy returns the output of a tool as a Result object. The result object can consist of a string, number, or a Boolean value. (See page 163)<\/span><\/p>\n<p><strong>Why are classes used as input parameters for geoprocessing tools?<\/strong><\/p>\n<p><span style=\"font-weight: 400\">ArcPy classes are often used as shortcuts for tool parameters that would otherwise have a more complicated equivalent. They are often used to avoid using lengthy strings.<\/span><\/p>\n<p><strong>Explain how ArcGIS Pro is licensed and how this impacts handling licensing when writing scripts.<\/strong><\/p>\n<p><span style=\"font-weight: 400\">Licensing effects which geoprocessing tools can be used by the user.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This chapter was alright compared to the others but there are definitely a few concepts I do not quite understand yet. ArcPy is built into ArcGIS Pro if you are using IDLE. Other IDE\u2019s like Spyder requires extra steps to <span class=\"readmore\"><a href=\"https:\/\/sites.owu.edu\/geog-293\/2021\/09\/26\/mcconkey-chapter-5\/\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":2121,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-chapter-notes"],"_links":{"self":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/users\/2121"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":3,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts\/88\/revisions\/94"}],"wp:attachment":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}