builder model: %name% from iteration give issue into raster calculator

419
2
06-24-2018 08:42 AM
yvanaltchenko
New Contributor

Hi,

I am building a model in builder model, with "Iterate raster" (i have a lot of raster which should be processed the same way and obviuosly i need to keep the original name %name%) and "raster calculator".

At one point, I have a raster called "VP_%name%" that I need to use into "raster calculator". The way raster calculator use the raster name is like "%ratser%". Thus for my raster "VP_%name%", the way to use it into raster calculator formula is to use "%VP_%name%%" but raster calculator doesn't recognize this raster (I believe, the  double %% or %VP_% is very confusing to get the name of the raster it has to use). How can I solve the problem?

I have 100s of raster to process and i can not manually, one raster after the other one. I am quite confortable with model builder but I dont know how to write in Python. I will appreciate your help.

0 Kudos
2 Replies
ChrisDonohue__GISP
MVP Alum

That's a tricky one.  I suspect the reason it doesn't like the filename is that the percent signs are used in Modelbuilder for Online Variable Substitution.  (You did not state it, so I am assuming you are not already using Inline Variable Substitution).

Examples of inline model variable substitution—Help | ArcGIS for Desktop 

One potential solution would be to do some processing before running the main model so as to rename the files to not have the percentage signs.  This would likely have to be done outside Modelbuilder, as the typical way to easily rename files is to employ Inline Variable Substitution.

There may be a way to employ "Escape characters" to allow Modelbuilder to realize that the percent signs are not part of online variable substitution.  Offhand, though, I don't know what those are for Modelbuilder.  As an example, in Python \ and r are used in certain cases to allow string input with certain characters to be used without being interpreted as something else.

Chris Donohue, GISP

0 Kudos
ChrisDonohue__GISP
MVP Alum

Found a possible solution for this in Modelbuilder:

How To: Create a model that makes a correctly formatted query from a string input with special chara... 

Chris Donohue, GISP