Sei sulla pagina 1di 6

UsingArcGISModelBuildertobatchprocessfiles

TheArcGISModelBuilderisatoolyoucanusetohelpprocessalargenumberoffilesinan
automatedfashion.ToopenanewModelBuilderdocument,eitherchooseModelBuilderfrom

theGeoprocessingmenu,orclicktheshortcutontheStandardToolbar: .Anew
ModelBuilderwindowshouldopen.

NearlyANYtoolfromArcToolboxtoolcanbeaddedtoaModelBuildermodel,andthistutorial
willonlyscratchthesurfaceofwhatcanbeaccomplishedinamodel.Ifyouareinterestedin
usingModelBuildertoautomatetheprocessingofyourfiles,IsuggestyoubeginwiththeHelp
topicAquicktourofModelBuilder.

AniteratorisaModelBuildertoolthatwillrunthesameprocessrepeatedlyuntilallinputshave
beenexamined.Thereareiteratorsforworkingwithtables(rowsandfieldvalues)andfor
processingallfilesinadirectoryoralldatasetsinaworkspacesuchasaGeodatabase.
PleasereadtheHelptopicExamplesofusingiteratorsinModelBuilderformoredetailsand
examples.

Theexamplebelowwillillustratehowtouseaniteratortoprocessanumberofwatershed
boundaries(polygons)inaGeodatabaseandconvertthemtorasterfiles.Whatevertoolyou
connecttotheiteratorsoutputwillberunoneachlayersequentially.

2013MichaelD.Hyslop,MichiganTechnologicalUniversityPage1of6
UsingArcGISModelBuildertobatchprocessfiles

ChoosetheInsertmenu,thenselecttheIteratorssubmenu. Select
FeatureClassesfromthelist. TheFeatureClassesiteratorwillbe
addedtoyourmodel.

DoubleclicktheIterateFeatureClassesboxinthemodel.Hereyoushouldselectyour
WorkspaceorFeatureDataSet,inthiscaseaGeodatabase.Pleasenotethatyour
Geodatabasenameandlocationwilldifferfromwhatisshownintheexamples.

Withjustthegeodatabaseselectedasyourworkspace,theiteratorwillprocesseveryfileit
finds.ThisisOKifyouhaveonlyfilesyouwishtoprocessintheworkspace.Ifyouhavea
subsetoffilesyoudliketoconvert,youcansetthreemoreoptionstorestrictwhichfilesare
actedupon.
2013MichaelD.Hyslop,MichiganTechnologicalUniversityPage2of6
UsingArcGISModelBuildertobatchprocessfiles

AWildcardletsyouenterfilenametextthatmustbematchedtobeprocessed.Thefilesinthe
examplegeodatabaseareallnamedWBD_HU12_04NNforwatershedboundary,Hydrologic
UnitCode12digit,andsubwatershedsbeginningwith04:0401,0402,and0403.

Ifyouhadotherfilesintheworkspaceyoudidnotwantconvertedtoraster,youcouldadda
wildcardWBD_HU12_04*toprocessonlythewatershedfiles.

IfyouselectaFeatureType,youcanrestrictprocessingtofilesofacertainclass(e.g.,point,
line,orpolygon).Inthiscase,IwillselectPolygon.

Finally,ifyouselecttheRecursivecheckbox,filesinsubdirectorieswillbeprocessed.

Youriteratorisnowsetupproperly.ClicktheOKbuttontocloseitswindow.Yourmodelwill
nowappeardifferentintheModelBuilderwindowbecauseyouhavemadechoicesaboutinput
files.Yourworkspacewillbeshownontheleft,andthefirstwatershedboundarywillbeshown
ingreenasoneoftheiteratorsoutputs.

2013MichaelD.Hyslop,MichiganTechnologicalUniversityPage3of6
UsingArcGISModelBuildertobatchprocessfiles

Ifyouweretorunthemodelnow,itwouldprocessquicklybecauseitwouldonlyreadeachfiles
nameintomemoryandwouldnotactonthefilesinanyotherway.Thetruepowerofaniterator,
though,isthatitwillperformthesameoperationonallinputfiles,sowenowneedtoaddthe
operationtothemodel,inthiscase,thePolygontoRastertool.

IfyouknowthelocationofthetoolinArcToolbox(ConversionTools>ToRaster>Polygon
ToRaster)youcanexpandthetoolboxanddragthetoolintothemodel.Itissimplerandfaster,

however,tousetheSearchwindow:ClicktheshortcuttoopenSearch ,typepolygonto
rasterintheSearchbox,andtaptheReturnkey(orclickthemagnifyingglassnexttothe
Searchbox).ThePolygontoRaster(Conversion)toolshouldshowupinyoursearchresults.
DragthetoolfromtheSearchwindowintothemodelandclose(x)orhide( )theSearch
Window.itwillappearinblackandwhite,indicatingyoustillhavechoicestomake.

Addaconnector betweentheiteratorsoutput(greenoval)andthePolygontoRaster
(P2R)tool.Simplyselecttheconnectortool,clickonceontheiteratoroutputbox,andclicka
secondtimeontheP2Rrectangle.SelectInputFeaturesfromthemenuthatappears.

AblueconnectorshouldnowrunbetweentheiteratorandtheP2Rtool.Selectthearrowtool

anddoubleclicktheP2Rrectangletosetsomeoptions.

2013MichaelD.Hyslop,MichiganTechnologicalUniversityPage4of6
UsingArcGISModelBuildertobatchprocessfiles

LeavetheInputFeaturessettothedefault.Thisvaluewillchangeeachtimetheiterator
processesanewfile.

ChangetheValueFieldtopointtothepolygonlayersuniqueidentifier.Fortheexample
watershedHUCfiles,thefieldnameisHUC_12.ThecontentsoftheValuefieldiswrittenasthe
cellvalueintheoutputraster,sothisisanimportantchoice.

ChangetheOutputRasterDatasetsoitstillpointstothegeodatabase,butalterthefilenameto
read%Name%_r.The%Name%isareplacementstringthatwillwritethesameoutputfile
nameastheinputfilename.The_rwillindicatethefileisarasterlayer(andkeepyoufrom
gettingafileexistserror.Ifyouomitthisstep,youwillendupwithoneoutputrasterwiththe
nameofyourfirstpolygonfilebutthecontentsofthelastoneprocessed.Theiteratorchanges
onlytheinputfilename.

SettheCellAssignmentTypetoMAXIMUM_AREA.

TheCellsizeiscalculatedbasedontheareacoveredbytheraster.Iwillbemergingthesefiles
laterwithsomeother30meterdata,sochangethecellsizevalueto30.

2013MichaelD.Hyslop,MichiganTechnologicalUniversityPage5of6
UsingArcGISModelBuildertobatchprocessfiles

ClickOKtosaveyourchanges.Ifyouwouldlikeyouroutputfilesaddedtoyourmap

automatically,rightclicktheP2Routputovalandchoose

Nowmightbeagoodtimetosaveyourmodel.Clickthediskicon onthetoolbarorchoose
SavefromtheModelmenu.

CrossyourfingersandValidateyourmodel.Usetheshortcut orselectValidateEntire
modelfromtheModelmenu.Ifyoureceivenoerrors,Runyourmodel,eitherusingtheshortcut
button ortheoptionundertheModelmenu.Dependingonthenumberoffilesyouare
processing,themodelmaytakeawhile.Ifitvalidatedcorrectly,youshouldreceivenoerrors.
Besuretoverifytheoutputfileslookcorrect.Ifyouseeanyproblems,checkeachofthetools
settingsandifnecessary,readthehelpfilesforeachtool!

TheModelBuildercansaveyouhoursoftediousworkwitha(relatively)smalltimeinvestment
upfront.AswithanyGIStool,process,oroperation,themoreyouusetheModelBuilder,the
easieritwillbetocreatemodelsefficiently.

2013MichaelD.Hyslop,MichiganTechnologicalUniversityPage6of6

Potrebbero piacerti anche