advanced geoprocessing and modelbuilder alawing/materials/essm462/   advanced geoprocessing

Download Advanced Geoprocessing and ModelBuilder alawing/materials/ESSM462/   Advanced Geoprocessing

Post on 09-Jul-2018

218 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    AdvancedGeoprocessingandModelBuilderConcepts

    A.MichelleLawingEcosystemScienceandManagementTexasA&MUniversityCollegeStaPon,TX77843alawing@tamu.edu

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    Announcements

    OPTIONAL:ReviseandresubmityourProposal!Oneweekyougetuptohalfthepointsbackthatyoulost.

    Dr.Smithiscomingnextweek(Nov.10th)tolectureaboutArcGISOnline.

    EstablishyourArcGISOnlineloginUsername:email_tamuPassword:password1

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ModelBuilder

    NowyouhavehadsomepracPcewithModelBuilder

    TodaywewilltalkaboutsomeadvancedprocessingopPons

    Thesearecommontoolsusedinanygeoprocessingframework

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ManagingIntermediateData

    GISanalysiscangetmessy Mostofthetoolsthatyourunproduceanoutputdataset

    Whenyouchainmanytoolstogetherthosedatasetsstartpilingup

    It'seasytowindupwithafolderfullofdatasetswithnameslikebuffers1,clippedbuffers1,intersectedandclippedbuffers1,raster2reclassified,etc.

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ManagingIntermediateData

    Inmostcases,youareconcernedwithjustthefinaloutputdataset

    Intermediatedataarejusttemporary Youonlyneedtokeepitaroundtorunthemodel,andthenitcanbedeleted

    ModelBuildercanmanageyourintermediatedataforyou

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ManagingIntermediateData

    ModelBuilderwillplaceintermediatedatainatemporarydirectorycalledthescratchworkspace

    ThescratchworkspaceisyouroperaPngsystem'stempdirectory

    YoucanconfigureittoexistinanotherlocaPon

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ManagingIntermediateData

    Youcanforcedatatogointothescratchworkspacebyusingthe%SCRATCHWORKSPACE%variableinthepath

    Forexample:%SCRATCHWORKSPACE%\myOutput.shp

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ManagingIntermediateData

    YoucanalsomarkanyelementinModelBuilderasIntermediateanditwillbedeletedakerthemodelisrun

    Bydefault,allderiveddataareIntermediatedata

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    LoopinginModelBuilder

    Looping,oriteraPon,istheactofrepeaPngaprocess

    Amainbenefitofcomputersistheirabilitytoquicklyrepeattasksthatwouldotherwisebemundane,cumbersome,orerror-proneforahumantorepeatandrecord

    Loopingisakeyconceptincomputerprogrammingandyouwilluseitokeningeoprocessing

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    LoopinginModelBuilder

    ModelBuildercontainsanumberofelementscalledIteratorsthatcandoloopinginvariousways

    Thenamesoftheseiterators,suchasForandWhileactuallymimicthetypesofloopingthatyoucanprograminPythonandotherlanguages

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    LoopinginModelBuilder

    Iterator:For

    DescripPon:IteratesoverastarPngandendingvaluebyagivenvalue.

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    LoopinginModelBuilder

    Iterator:While

    DescripPon:Executes"while"acondiPonistrueorfalsefortheinputorsetofinputs

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    LoopinginModelBuilder

    IterateFeatureSelecPon-Iteratesoverfeaturesinafeatureclass

    IterateRowSelecPon-Iteratesoverrowsinatable IterateFieldValues-Iteratesovereachvalueinafield

    IterateMulPvalue-Iteratesoveralistofvalues IterateDatasets-IteratesoverdatasetsinaWorkspaceorFeatureDataset

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    LoopinginModelBuilder

    IterateFeatureClasses-IteratesoverfeatureclassesinaWorkspaceorFeatureDataset

    IterateFiles-Iteratesoverfilesinafolder IterateRasters-IteratesoverrastersinaWorkspaceoraRasterCatalog

    IterateTables-Iteratesovertablesinaworkspace IterateWorkspaces-Iteratesoverworkspacesinafolder

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    Eachiteratorhasasetofparametersthatmaydifferfromtheotheriterators

    Theoverallstructureofalliteratortoolsisverysimilar

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    IterateFeatureClassesrequiresanInputWorkspacewhereallthefeatureclassestoiteratethrougharestored

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    WildcardandFeatureTypeareusedtorestrictwhatfeatureclassesintheworkspaceareiterated

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    Wildcardlimitsthefeatureclassesbytheirnames FeatureTypelimitsthefeatureclassesbytheirfeaturetypes

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    RecursiveisusedtocontroltheiteraPonoverfeatureclasseswithinsubfoldersintheworkspace

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    IterateFeatureClasseshastwooutputvariables:theoutputfeatureclassandthenameofthefeatureclass

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    Theoutputfeatureclasscanbeconnectedtothenexttoolforprocessing

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    NamecanbeusedforinlinevariablesubsPtuPon

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    UnderstandinganIterator

    Forexample,iftheBuffertoolwasaddedtothemodel,andtheFeatureClassvariablewasconnectedtothetool,everyfeatureclassintheworkspacewouldbebuffered

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    Notes

    Onlyoneiteratorcanbeusedpermodel. TheopPonstoaddanotheriteratorwillbedisabledifoneiteratorexistsinthemodel.

    Ifaniteratorisaddedtoamodel,alltoolsinthemodeliterateforeachvalueintheiterator.

    Ifyoudonotwanttoruneachtoolinthemodelforeachiteratedvalue,createasubmodel/modelwithinamodelthatcontainsonlytheiteratorandadditasamodeltoolintothemainmodel.

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    Notes

    IfamodelcontaininganiteratorisexportedtoaPythonscript,thescriptwillnotincludetheitera1onlogic.

    PythonlisPnglogiccanbeaddedtothescripttoachieveasimilareffect.

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ExampleusinganIterator

    WewillusetheIterateFeatureClassesiteratorto1. Projecteveryfeatureclassinaworkspace2. NameeachProjecttooloutputdynamicallybased

    ontheinputnameusinginlinevariablesubs1tu1on

    3. Addanewfieldtoeachfeatureclass.

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ExampleusinganIterator

    AninputworkspaceisspecifiedforIterateFeatureClassestoiteratethrougheveryfeatureclassinthatworkspace.

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ExampleusinganIterator

    Featureclassestoiteratethrougharerestrictedbyspecifyingawildcardandfeaturetype(onlypolygonfeatureclasseswithwithIwillbeiteratedthrough)

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ExampleusinganIterator

    IterateFeatureClassesproducestwooutputs:thefeatureclassiteratedthroughandthenameofthefeatureclass

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ExampleusinganIterator

    ThefeatureclassvariableisconnectedastheinputtotheProjecttool

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ExampleusinganIterator ThefeatureclassnamevariableisusedforinlinevariablesubsPtuPontodynamicallynameeachoutputfromtheProjecttoolwiththesamenameoftheinputfeatureclass

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    ExampleusinganIterator AnewfieldisaddedtoeveryfeatureclassbyconnecPngtheAddFieldtool.

  • ESSM/GEOG462:AdvancedGISEcosystemScienceandManagement|TexasA&MUniversity(c)2015,A.MichelleLawing

    AccessingIteratorsinModelBuilder

    Insertmenu-ClickInsert>Iteratorsandchooseaniteratortoaddtothemodel

    Shortcutmenu-Right-clickinopenspaceinthemodel,clickIterators,thenchoosetheiteratortoaddtothemodel