intermediate modelbuilder - esri€¦ · -- arcgis desktop online help arcgis desktop online help...

35
Intermediate ModelBuilder Intermediate ModelBuilder Kevin Armstrong Kevin Armstrong ESRI Charlotte ESRI Charlotte ESRI Charlotte ESRI Charlotte

Upload: others

Post on 19-Jun-2020

41 views

Category:

Documents


2 download

TRANSCRIPT

Intermediate ModelBuilderIntermediate ModelBuilder

Kevin ArmstrongKevin ArmstrongESRI CharlotteESRI CharlotteESRI CharlotteESRI Charlotte

What do you need to know to become proficient at What do you need to know to become proficient at yybuilding models?building models?

•• Know how to use Know how to use geoprocessinggeoprocessing toolstools–– Complex operations are accomplished by combining simple Complex operations are accomplished by combining simple

operations.operations.–– Learn how to combine tools in the correct order.Learn how to combine tools in the correct order.

•• Know how to use Know how to use ModelBuilderModelBuilder techniquestechniques

AgendaAgendaggModelBuilder TechniquesModelBuilder Techniques

•• Interactive inputInteractive input•• ListsLists•• Inline variablesInline variables•• Model iterationModel iteration•• Model iterationModel iteration•• FeedbackFeedback•• Network analysisNetwork analysis•• Model only toolsModel only tools

Making a Model a ToolMaking a Model a Toolgg

•• Creating model elements for parametersCreating model elements for parameters•• Setting data type on model elementsSetting data type on model elements•• Setting filters on model parametersSetting filters on model parameters•• Setting symbology on model parametersSetting symbology on model parameters•• Setting symbology on model parametersSetting symbology on model parameters•• Using variables for environment settingUsing variables for environment setting•• Using the feature set data type to make models interactiveUsing the feature set data type to make models interactive

DemoDemoDemoDemo

Buffer and Clip ExampleBuffer and Clip Example

•• Make the model interactive.Make the model interactive.

Buffer and Clip ExampleBuffer and Clip Example

•• Use a list.Use a list.

Parcel Report Example Parcel Report Example

•• Given a parcel ID, report all the parcels within 500 feet.Given a parcel ID, report all the parcels within 500 feet.•• Create a model where only the parcel ID is entered.Create a model where only the parcel ID is entered.•• Export the list of parcels to an HTML file.Export the list of parcels to an HTML file.

DemoDemoDemoDemo

Parcel Report: Create a model parameter for the Parcel Report: Create a model parameter for the parcel ID.parcel ID.

•• Create a variable for the parcel ID in the model.Create a variable for the parcel ID in the model.–– Use the String data type.Use the String data type.

•• Rename the variable to “Rename the variable to “ParcelIDParcelID.”.”•• Make the variable a model parameter.Make the variable a model parameter.Make the variable a model parameter.Make the variable a model parameter.

Parcel Report: Use Parcel Report: Use inline variable substitution inline variable substitution to to put the parcel ID in the selection expression.put the parcel ID in the selection expression.

•• Note the single quotes around the variable name.Note the single quotes around the variable name.–– You have to supply proper quoting in the expression.You have to supply proper quoting in the expression.

Inline variable substitution is used to make Inline variable substitution is used to make parameter values more flexible.parameter values more flexible.

•• Any string or path parameter can include inline variables.Any string or path parameter can include inline variables.

•• Use %<keyword>% to indicate inline variable.Use %<keyword>% to indicate inline variable.

•• KeywordsKeywords–– Variable namesVariable names–– Environment setting namesEnvironment setting names–– BuiltBuilt--in keywordsin keywords

•• %n% is the current iteration number.%n% is the current iteration number.%%ii% i th t li t i d% i th t li t i d•• %%ii% is the current list index.% is the current list index.

•• %v% is the current series value.%v% is the current series value.

Inline Variable Substitution ExamplesInline Variable Substitution Examples

•• Calculate Value expressionCalculate Value expression––%%StartYearStartYear%% + + %n%%n%

•• Calculate Field expressionCalculate Field expression•• Calculate Field expressionCalculate Field expression–– !!shape.Areashape.Area! * ! * %%conversion_factorconversion_factor%%–– [[airport_idairport_id] = “] = “%%airport_idairport_id%%””

–– Make sure to include quotes in the expression!Make sure to include quotes in the expression!

•• Path to datasetPath to dataset––%scratchworkspace%%scratchworkspace%\\out.shpout.shp––DirectoryDirectory\\outout%n%n%%

Parcel Report: Export to HTMLParcel Report: Export to HTML

•• Download Table To Html toolDownload Table To Html tool–– http://resources.esri.com/geoprocessing/index.cfm?fa=codeGhttp://resources.esri.com/geoprocessing/index.cfm?fa=codeG

alleryDetails&scriptID=15712alleryDetails&scriptID=15712

•• Also includes Table To ExcelAlso includes Table To Excel–– Shows how to call Excel from PythonShows how to call Excel from Python

Use model iteration to run the parcel report for Use model iteration to run the parcel report for more than one parcel.more than one parcel.

Use model iteration to run the parcel report for Use model iteration to run the parcel report for more than one parcel.more than one parcel.

•• Modify the “Modify the “ParcelIDParcelID” variable to be a ” variable to be a seriesseries..–– A series is a list used by model iterations.A series is a list used by model iterations.–– The model iteration determines which value from a series is The model iteration determines which value from a series is

used.used.

Use model iteration to run the parcel report for Use model iteration to run the parcel report for more than one parcel.more than one parcel.

•• Set the model iteration to run based on the Parcel IDs Set the model iteration to run based on the Parcel IDs variable.variable.

•• The model will run for each value in the series.The model will run for each value in the series.

How to iterate a model based on values in a tableHow to iterate a model based on values in a table

•• Option 1: Load the values into a series variable.Option 1: Load the values into a series variable.

How to iterate a model based on values in a tableHow to iterate a model based on values in a table

•• Option 2: Use a script tool to extract the values from the Option 2: Use a script tool to extract the values from the table.table.

•• Useful if the table may change for each model runUseful if the table may change for each model run•• Download Iterate Field Value toolDownload Iterate Field Value toolDownload Iterate Field Value toolDownload Iterate Field Value tool

–– http://resources.esri.com/geoprocessing/index.cfm?fa=codeGhttp://resources.esri.com/geoprocessing/index.cfm?fa=codeGalleryDetails&scriptID=15710alleryDetails&scriptID=15710

How to iterate a model based on values in a tableHow to iterate a model based on values in a table

•• The Iterate Field Value tool extracts the field value for the The Iterate Field Value tool extracts the field value for the current iteration.current iteration.

•• Inputs: Table, field, and iteration number Inputs: Table, field, and iteration number %n%%n%•• Outputs: Value and ContinueOutputs: Value and ContinueOutputs: Value and ContinueOutputs: Value and Continue

–– Value contains the field value.Value contains the field value.–– Continue is set to false when the end of the table is reached. Continue is set to false when the end of the table is reached.

How to make the number of iterations based on a How to make the number of iterations based on a condition in the modelcondition in the model

•• Set model iteration properties to “Run the model until this Set model iteration properties to “Run the model until this variable is false.”variable is false.”

In this case, use theIn this case, use theIn this case, use theIn this case, use the“Continue” variable.“Continue” variable.

DriveDrive--Time Demographics ExampleTime Demographics Examplegg

•• For a location, determine the population within driveFor a location, determine the population within drive--time time zones.zones.

DriveDrive--Time DemographicsTime Demographicsgg

•• Use Service Area Network Analysis Layer.Use Service Area Network Analysis Layer.•• Use Add Locations to add the drive time source.Use Add Locations to add the drive time source.•• Use Solve to compute the driveUse Solve to compute the drive--time zones.time zones.

Select Data ToolSelect Data Tool

The Select Data tool is used to expose The Select Data tool is used to expose subdatasetssubdatasets from the from the results of tools like Solve, Import From CAD, Split.results of tools like Solve, Import From CAD, Split.

Select Data ExampleSelect Data Example

•• Use Use Select Data Select Data to get the “polygons” to get the “polygons” sublayersublayer from the from the Service Area layer.Service Area layer.

Model Only ToolsModel Only Toolsyy

•• Select DataSelect Data•• Calculate ValueCalculate Value•• Merge BranchMerge Branch

–– These tools are only useful in ModelBuilderThese tools are only useful in ModelBuilderThese tools are only useful in ModelBuilder.These tools are only useful in ModelBuilder.–– The are not needed in scripting.The are not needed in scripting.

Drive Time DemographicsDrive Time Demographicsgg

•• Use Make Feature Layer to make the population field a Use Make Feature Layer to make the population field a ratio ratio field field so that Intersect will proportionally split the value by so that Intersect will proportionally split the value by area.area.

Make Feature Layer is your friend.Make Feature Layer is your friend.y yy y

•• Can use to get a subset selection without creating a new Can use to get a subset selection without creating a new feature classfeature class

•• Can rename fieldsCan rename fields•• Can turn fields offCan turn fields offCan turn fields offCan turn fields off•• Can set fields to be ratioCan set fields to be ratio•• Used to create a layer for Select by Attribute, Select by Used to create a layer for Select by Attribute, Select by

Location and Add JoinLocation and Add JoinLocation, and Add JoinLocation, and Add Join

DriveDrive--Time DemographicsTime Demographicsgg

•• Use Dissolve with statistics fields to sum the population by Use Dissolve with statistics fields to sum the population by drivedrive--time zones.time zones.

Managing model tool parametersManaging model tool parametersg gg g

•• Variable Name = Parameter Label/NameVariable Name = Parameter Label/Name•• Variable Data Type = Parameter Data TypeVariable Data Type = Parameter Data Type•• You can change “Optional” to “Required.”You can change “Optional” to “Required.”•• You can specify a filterYou can specify a filter•• You can specify a filter.You can specify a filter.•• You can specify output symbology.You can specify output symbology.

How to control the parameter filterHow to control the parameter filter

•• Model Properties/Parameters property pageModel Properties/Parameters property page•• Filter propertyFilter property

–– For the string data type, specify a choice list.For the string data type, specify a choice list.–– For the feature class data type, specify the geometry type: For the feature class data type, specify the geometry type: yp , p y g y ypyp , p y g y yp

Point, Line, Polygon . . Point, Line, Polygon . . ..

How to control the How to control the symbologysymbology of the outputof the outputy gyy gy

•• Set the symbology property on the output variable.Set the symbology property on the output variable.

How to control the How to control the symbologysymbology of the outputof the outputy gyy gy

•• The layer file defines the symbology that will be used when The layer file defines the symbology that will be used when a layer is created for the output geodataset.a layer is created for the output geodataset.

•• Classified legends will update if the classification type isClassified legends will update if the classification type isClassified legends will update if the classification type is Classified legends will update if the classification type is not “manual” not “manual” (9.3).(9.3).

•• Unique value legends will update if “all other values” isUnique value legends will update if “all other values” is•• Unique value legends will update if all other values is Unique value legends will update if all other values is false false (9.3).(9.3).

•• ArcGIS HelpArcGIS Help•• ArcGIS HelpArcGIS Help––http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?Tohttp://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?To

picName=Setting_symbology_for_output_datapicName=Setting_symbology_for_output_data

Controlling Model ExecutionControlling Model Executiongg

•• PreconditionsPreconditions

ResourcesResources

•• OnlineOnline-- http://resources.esri.com/geoprocessinghttp://resources.esri.com/geoprocessing-- http://arcscripts.esri.comhttp://arcscripts.esri.com-- ArcGIS Desktop online helpArcGIS Desktop online help

•• Virtual CampusVirtual CampusGeoprocessing Using ModelBuilderGeoprocessing Using ModelBuilder**Geoprocessing CAD Data with ArcGISGeoprocessing CAD Data with ArcGIS**Geoprocessing CAD Data with ArcGISGeoprocessing CAD Data with ArcGISGeoprocessing with ArcGIS DesktopGeoprocessing with ArcGIS DesktopGetting Started with Scripting in ArcGIS 9Getting Started with Scripting in ArcGIS 9**I t tI t t L dL d•• InstructorInstructor--LedLedIntroduction to ArcGIS IIIntroduction to ArcGIS IIAdvanced Analysis with ArcGISAdvanced Analysis with ArcGISIntroduction to GP Scripts with PythonIntroduction to GP Scripts with PythonWriting Advanced GP Scripts with PythonWriting Advanced GP Scripts with Python * Free course* Free course