Page 1
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
AdvancedGeoprocessingandModelBuilderConcepts
A.MichelleLawingEcosystemScienceandManagementTexasA&MUniversityCollegeStaPon,[email protected]
Page 2
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
Announcements
• OPTIONAL:ReviseandresubmityourProposal!Oneweek–yougetuptohalfthepointsbackthatyoulost.
• Dr.Smithiscomingnextweek(Nov.10th)tolectureaboutArcGISOnline.
• EstablishyourArcGISOnlineloginUsername:email_tamuPassword:password1
Page 3
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ModelBuilder
• NowyouhavehadsomepracPcewithModelBuilder
• TodaywewilltalkaboutsomeadvancedprocessingopPons
• Thesearecommontoolsusedinanygeoprocessingframework
Page 4
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ManagingIntermediateData
• GISanalysiscangetmessy• Mostofthetoolsthatyourunproduceanoutputdataset
• Whenyouchainmanytoolstogetherthosedatasetsstartpilingup
• It'seasytowindupwithafolderfullofdatasetswithnameslikebuffers1,clippedbuffers1,intersectedandclippedbuffers1,raster2reclassified,etc.
Page 5
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ManagingIntermediateData
• Inmostcases,youareconcernedwithjustthefinaloutputdataset
• Intermediatedataarejusttemporary• Youonlyneedtokeepitaroundtorunthemodel,andthenitcanbedeleted
• ModelBuildercanmanageyourintermediatedataforyou
Page 6
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ManagingIntermediateData
• ModelBuilderwillplaceintermediatedatainatemporarydirectorycalledthescratchworkspace
• ThescratchworkspaceisyouroperaPngsystem'stempdirectory
• YoucanconfigureittoexistinanotherlocaPon
Page 7
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ManagingIntermediateData
• Youcanforcedatatogointothescratchworkspacebyusingthe%SCRATCHWORKSPACE%variableinthepath
• Forexample:%SCRATCHWORKSPACE%\myOutput.shp
Page 8
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ManagingIntermediateData
• YoucanalsomarkanyelementinModelBuilderasIntermediateanditwillbedeletedakerthemodelisrun
• Bydefault,allderiveddataareIntermediatedata
Page 9
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
LoopinginModelBuilder
• Looping,oriteraPon,istheactofrepeaPngaprocess
• Amainbenefitofcomputersistheirabilitytoquicklyrepeattasksthatwouldotherwisebemundane,cumbersome,orerror-proneforahumantorepeatandrecord
• Loopingisakeyconceptincomputerprogrammingandyouwilluseitokeningeoprocessing
Page 10
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
LoopinginModelBuilder
• ModelBuildercontainsanumberofelementscalledIteratorsthatcandoloopinginvariousways
• Thenamesoftheseiterators,suchasForandWhileactuallymimicthetypesofloopingthatyoucanprograminPythonandotherlanguages
Page 11
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
LoopinginModelBuilder
Iterator:For
DescripPon:IteratesoverastarPngandendingvaluebyagivenvalue.
Page 12
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
LoopinginModelBuilder
Iterator:While
DescripPon:Executes"while"acondiPonistrueorfalsefortheinputorsetofinputs
Page 13
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
LoopinginModelBuilder
• IterateFeatureSelecPon-Iteratesoverfeaturesinafeatureclass
• IterateRowSelecPon-Iteratesoverrowsinatable• IterateFieldValues-Iteratesovereachvalueinafield
• IterateMulPvalue-Iteratesoveralistofvalues• IterateDatasets-IteratesoverdatasetsinaWorkspaceorFeatureDataset
Page 14
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
LoopinginModelBuilder
• IterateFeatureClasses-IteratesoverfeatureclassesinaWorkspaceorFeatureDataset
• IterateFiles-Iteratesoverfilesinafolder• IterateRasters-IteratesoverrastersinaWorkspaceoraRasterCatalog
• IterateTables-Iteratesovertablesinaworkspace• IterateWorkspaces-Iteratesoverworkspacesinafolder
Page 15
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• Eachiteratorhasasetofparametersthatmaydifferfromtheotheriterators
• Theoverallstructureofalliteratortoolsisverysimilar
Page 16
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• IterateFeatureClassesrequiresanInputWorkspacewhereallthefeatureclassestoiteratethrougharestored
Page 17
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• WildcardandFeatureTypeareusedtorestrictwhatfeatureclassesintheworkspaceareiterated
Page 18
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• Wildcardlimitsthefeatureclassesbytheirnames• FeatureTypelimitsthefeatureclassesbytheirfeaturetypes
Page 19
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• RecursiveisusedtocontroltheiteraPonoverfeatureclasseswithinsubfoldersintheworkspace
Page 20
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• IterateFeatureClasseshastwooutputvariables:theoutputfeatureclassandthenameofthefeatureclass
Page 21
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• Theoutputfeatureclasscanbeconnectedtothenexttoolforprocessing
Page 22
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• NamecanbeusedforinlinevariablesubsPtuPon
Page 23
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
UnderstandinganIterator
• Forexample,iftheBuffertoolwasaddedtothemodel,andtheFeatureClassvariablewasconnectedtothetool,everyfeatureclassintheworkspacewouldbebuffered
Page 24
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
Notes
• Onlyoneiteratorcanbeusedpermodel.• TheopPonstoaddanotheriteratorwillbedisabledifoneiteratorexistsinthemodel.
• Ifaniteratorisaddedtoamodel,alltoolsinthemodeliterateforeachvalueintheiterator.
• Ifyoudonotwanttoruneachtoolinthemodelforeachiteratedvalue,createasubmodel/modelwithinamodelthatcontainsonlytheiteratorandadditasamodeltoolintothemainmodel.
Page 25
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
Notes
• IfamodelcontaininganiteratorisexportedtoaPythonscript,thescriptwillnotincludetheitera1onlogic.
• PythonlisPnglogiccanbeaddedtothescripttoachieveasimilareffect.
Page 26
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ExampleusinganIterator
WewillusetheIterateFeatureClassesiteratorto1. Projecteveryfeatureclassinaworkspace2. NameeachProjecttooloutputdynamicallybased
ontheinputnameusinginlinevariablesubs1tu1on
3. Addanewfieldtoeachfeatureclass.
Page 27
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ExampleusinganIterator
• AninputworkspaceisspecifiedforIterateFeatureClassestoiteratethrougheveryfeatureclassinthatworkspace.
Page 28
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ExampleusinganIterator
• Featureclassestoiteratethrougharerestrictedbyspecifyingawildcardandfeaturetype(onlypolygonfeatureclasseswithwithIwillbeiteratedthrough)
Page 29
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ExampleusinganIterator
• IterateFeatureClassesproducestwooutputs:thefeatureclassiteratedthroughandthenameofthefeatureclass
Page 30
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ExampleusinganIterator
• ThefeatureclassvariableisconnectedastheinputtotheProjecttool
Page 31
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ExampleusinganIterator• ThefeatureclassnamevariableisusedforinlinevariablesubsPtuPontodynamicallynameeachoutputfromtheProjecttoolwiththesamenameoftheinputfeatureclass
Page 32
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
ExampleusinganIterator• AnewfieldisaddedtoeveryfeatureclassbyconnecPngtheAddFieldtool.
Page 33
ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing
AccessingIteratorsinModelBuilder
• Insertmenu-ClickInsert>Iteratorsandchooseaniteratortoaddtothemodel
• Shortcutmenu-Right-clickinopenspaceinthemodel,clickIterators,thenchoosetheiteratortoaddtothemodel