Select to view content in your preferred language

Error while using ModelBuilder to Tabulate Area of overlapping bufferzones

1218
9
10-16-2019 11:50 AM
JonAdamski
New Contributor II

I'm looking into how much open and close canopy falls within given buffer zones. My buffer zones are a polygon layer created from point sites, but canopy data is a raster with 2 types of data, open or closed canopy. It was pulled from PASDA and has a fairly fine resolution, which is why some other solutions (Converting to polygon) did not work.

This is my first time using ModelBuilder, but I'm attempting to use the tabulate area tool in ModelBuilder by iterating through each row of my buffer zones, tabulating area, and then collecting the new tables. Finally, I use a second model (With the iterating model as a sub-model) to merge these tables together into one output (Added images of models).

However, I'm getting error 001156 (Attached screen shot of error) at the end.

Does anyone have a suggestion to get around this?

It suggests that the string length of columns is limited (This doesn't seem to be the case), or that there is data of one type being written to a column that contains a separate data type. All of the columns from Tabulate area are the same, however.

Unfortunately, I cannot include a screenshot of my tables as they contain locality information for sensitive species. The tables from Tabulate Area have 4 columns (Object ID, Name, Closed Canopy, Open Canopy)

On another forum it was suggested that I use the append tool instead, but this yielded the same error. Someone else suggested it was because there were spaces in my site names, removing the spaces did not fix the error.

https://imgur.com/a/lpJVe8x

0 Kudos
9 Replies
JonAdamski
New Contributor II

So I've figured out the problem.. In the field map, when I go to run the merge tool, it's setting the field length to 0. If I change the length to any other number, it still errors out. BUT, if I change it again after the error, it works fine. Does anyone know why this is the case or what I can do to stop this and prevent from having to run each tool twice?

0 Kudos
JonAdamski
New Contributor II

IE: When I set up the merge tool, it's only population the field map with "Name", field length of 0. I changed this to 100 and ran the model. It returned error 001156. Now, the field map is populated with the column names (Name, Value_0, Value_1). I can now set the length of name to 100, and the model runs fine.

0 Kudos
curtvprice
MVP Esteemed Contributor

I have found the prevalidated field map can sometimes cause problems, and have worked around it by using a Calculate Value function (writing a python function) to build the field map at runtime instead of during model validation. You may be handling this fine just by editing the field map in the model, which will work unless you change the inputs.

0 Kudos
JonAdamski
New Contributor II

Thank you for the response. I don't suppose you know of a thread I can follow to do that? I'm very inexperienced with python. I took class for it, and the professor missed 3 of 15 classes, and showed up an hour or more late to the rest of them. It was incredibly irritating. I'll give it a try tomorrow and see if I can find something to imitate. Thanks again!

0 Kudos
curtvprice
MVP Esteemed Contributor

Re: Merge Buffers After Creating/Calculating Field‌ has an example. Wow, that is irritating. As a prof who does 12 hours days all term to keep up I feel like I have been taking up this guys slack, ha.

0 Kudos
JonAdamski
New Contributor II

Yes, it was incredibly frustrating. The only real thing I took away from that class was that python scripts were usable in ArcMap, and that I could use ModelBuilder to streamline processes (Though he only gave us one example). I sent the complaint to the chair and he shrugged it off. More annoyingly, the chair was on my thesis committee (As he's the only GIS expert on campus). The missed my first committee meeting, came to second, and then showed up 10 minutes late to my thesis defense where he admitted he did not actually read my thesis. So, it's been a good time, overall.

Anyways, I'm sorry to keep harassing you with questions but I'm doing something wrong. I made the script you reference in that other thread and added it to the model, but it's erroring out. I'm not sure if I messed up the parameters when setting it up (Data type = Field Mappings, set it to output)

https://imgur.com/a/vvHET7R 

Attached are images of the new model setup, the error, and the parameters. Thank you so much for your help and patience.

0 Kudos
curtvprice
MVP Esteemed Contributor

The approach I was suggesting in the thread was using the Calculate Value tool, not an external script. The %model_variable% syntax only works within ModelBuilder, it would not work in an external script.

I have considered putting a proposal to Esri press for a ModelBuilder book and this would be one of the things I would include in a chapter of modelbuilder cookbook calculate value codes!

0 Kudos
JonAdamski
New Contributor II

Alright, I definitely misunderstood. Going to try now. So I should pass the interate model to the Calculate Value tool, then pass that to merge?

0 Kudos
JonAdamski
New Contributor II

I can't get it to work. Sorry that I'm not following. Again, I have very little experience with python and modelbuilder. Attached are the script in the Calculate Value tool and what the new model looks like. Using your script from that other thread in Calculate Value and outputting as Field Mapping. Run as a pre-condition from the iterator model and passed the output from Calculate Value to the Merge tool as a field map. Attached are images. Thank you, once again, for all of the help. I'm fearing I may just have to do this manually. (FYI, I'd absolutely be interested in a book like that)

https://imgur.com/a/stdIavq

0 Kudos