[GIS] Inputting multiple featureclasses into Merge tool using ModelBuilder

arcgis-10.0arcpygeoprocessingmergemodelbuilder

So I have 490 point fc's in a single directory with uniform spatial features, field names/datatypes. I'm trying to figure out how to consecutively input the first seven fc's into the merge tool, create a new merged fc, and then iterate the model until 70 new merged fc's are created.

I know how to iterate single fc's as input into a tool, but not multiple features per x number of iterations.

I have some code below that uses list, an array, and a count system that does what i need for another GP operation. How can I translate this into modelbuilder's variables/methods? I am using modelbuilder because I was having trouble mapping fields for merge in python

try:
    # Create list of rasters
    rasters = arcpy.ListRasters("*", "tif")
    rastersCount = len(rasters)

    counter = 0
    weekNum = 1

    while counter < rastersCount:
        #collect 7 consecutive rasters
        weekRasters = []
        for i in range(counter,(counter+7)):
        weekRasters.append(rasters[i])

        # Execute CellStatistics (one can use list of rasters directly here)
        outCellStatistics = CellStatistics(weekRasters, "SUM", "NODATA")
        # Save the output
        outRasterName = "week_"+ str(weekNum)
        outCellStatistics.save("D:/dailyrainfall/nueces_dailyrainfall_rasterized/" + outRasterName )

        counter += 7
        weekNum += 1
except:
    # If an error occurred while running a tool, then print the messages.
    print arcpy.GetMessages()

Using ArcGIS 10 (ArcInfo) SP4 with all extensions

Best Answer

I'm not sure you can transfer that type of logic to modelbuilder. But are you aware that you can wire up a script to a model builder tool? Why bother with any thing else as you have the framework of logic in your existing script (it just needs tweaking)? Once you add your script as a "tool script" it looks and behaves like any other geoprocessing tool.

Related Question