2

I'm new to ModelBuilder.

I have a large series of rasters divided into two categories, let's call it Type A & Type B, a pair for each of a few hundred date/time snapshots. The date/time for the snapshot is in the file name (roughly in the middle with a standard structure), and the Type is in the filename (near but not at the end). They're all in a folder together. I need to calculate a new raster for each date/time snapshot using the Type A raster & Type B raster to do so.

I know how to iterate rasters, and I know how to use raster calculator but how can I can store a raster while I'm iterating so that I can use both A & B?

The way the file names are, Iterate Rasters will run through Type A then Type B for each date before moving on to A for the next date, which I think is exactly what I want.

I just don't know much about how the variables work in ModelBuilder or ArcPy or even Python for that matter, so this is where I'm stuck.

I figure there's a few different ways to do it, and two that I've tried and failed (due to my limited knowledge of how to set it up) are:

  1. Storing Raster A in a variable and when Iterate Rasters hits raster B, having it realize it's B (through a count variable or through a substring in the file name, etc.) and using the pulled-up raster B and stored raster A to calculate a new raster, then clearing both my raster storage and whatever other variables I have.
  2. Using a built-in function like Collect Values and clearing that every two iterations. I'd have to know how to clear that and also how to calculate a raster using a reference to its position or whatever in Collect Values.

Can anyone explain in more detail (variable type, path, setup, code for things, etc.) how I could do either of those?

Where I'm roughly at

Can anyone tell me the code necessary in a Calculate Value function (or whatever else) to extract the characters between two known strings in a filename, that would give me the date?

closed as unclear what you're asking by PolyGeo Aug 6 '16 at 3:54

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    From reading your explanation it sounds like if you want to continue in model builder then you need to be using sub-models, Master model iterating over type A and sub-model iterating over type B. As you say you have several hundred rasters to process I would suggest forgetting modelbuilder and do it all in python. I think it would be really helpful if you edit your question to actually show some example file names. – Hornbydd May 2 '16 at 19:38