I am using ModeBuilder to project many raster files from one coordinate system to another. I'd like the output file names to be different than the input.

The file names currently end in "utm83" but I want to remove that and add "NAD83". I know how to use the %name% variable to keep the same name, but I'm not sure how to alter that for my desired effect.

It seems like I should be able to use the "Calculate Value" with an expression like LEFT(%name%, -5) to get this result but I can't figure it out.

Here is what my model looks like: enter image description here

  • Have you tested your different ideas(i.e. trial and error)? and/or considered converting your model to Python? – GeoSharp Mar 22 '14 at 10:10
  • @JamesSLC I've tried some different things with Calculate Value but I haven't come up with a solution that works. Unfortunately I don't know enough Python to be able to work with the model that way even if I converted it from the model. – Sara Barnes Mar 24 '14 at 12:46

Here is one way it can be done using the Calculate Value tool as you suggested.

I put the code in the code block for easier reading...but can be done just as easily right in the expression line only:

"%Name%".rstrip("utm83") + "NAD83"

The expression could strip a certain number of characters instead of the string "utm83" as I have done:

"%Name%"[:-5] + "NAD83"

ModelBuilder Image

Large Image

  • Thanks for the answer. This is what I was looking for. Unfortunately I'm having some trouble getting it to work. I set it up just like your model and Calculate Values window as far as I can tell, but it's still kicking out the original file name. What do you have for the name of your "Output Raster Dataset" in the Project Raster tool? I'm just using %name%. Do I need to change that? Thanks again. – Sara Barnes Mar 24 '14 at 12:48
  • Hello Sara. The output raster parameter for the Project tool should also use an inline variable. You should be using the value that you have calculated. Referring to my example, your should use %output_value% (or whatever your output of the Calculate tool is called in the green oval). – Adam Mar 24 '14 at 21:41
  • I should have included this in the original answer...but here is a screenshot of what the Project Raster Tool parameters should look like: Project Raster parameters – Adam Mar 24 '14 at 21:46
  • 1
    @ amarinel Thank you. This worked for me. For future reference, I had to make a few modifications to get it to work correctly. They were: 1) to add the file extension to the Calculate Value, like this: rstrip("utm83.jp2") and 2) to add the file extension to the Project Raster Output Dataset name, like this \%output%.jp2. Thanks again! – Sara Barnes Mar 25 '14 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.