0

I am using Model Builder in ArcGIS Pro to set up an iterative work flow to analyse satellite images.

The input tiff files have long files names such as: 5023109_2010-06-21_RE1_3A_Analytic_clip.tif

I am trying to use inline substitution to give output rasters shorter filenames. For example: "R"+"%Name%"[10:17], where Name is the variable representing the name of the input tiff.

I have read other discussions on this, but haven’t managed to solve the problem.

  • For example: in the model in Make Raster Layer, Parameter: Output raster layer name is "R"+"%Name%"[10:17] This doesn’t create the expected raster layer name R10-06-21, so the next step falls over. Exporting the model to python, produces the following code for the MakeRasterLayer step: # Process: Make Raster Layer arcpy.MakeRasterLayer_management(in_raster=Raster, out_rasterlayer=v_R____Name___10_17_, where_clause="", envelope="377500 6182870 380000 6184300", band_index="5") – user165128 Jun 10 '20 at 4:06
1

I believe the issue is in how your are slicing the string and then concatenating that's causing it to fail. If you are constructing new names in this manner you should really do it in the Calculate Value tool as shown below. Trying to slice something within a parameter is unlikely to work or at best be confusing as to what it is you are really trying to achieve.

Model

The Calculate value tool is set up as shown:

Calculate Value tool

Notes:

  1. Data type is set to any value, string did not seem to work
  2. The output of the calculate value tool is a precondition to the Make raster Layer tool
  3. The Raster dataset coming out of the iterator is the input into Make Raster Layer but is also a precondition to the Calculate Value tool. This ensures correct order of tool runs.
  4. You use the output of calculate values as inline substitution for the raster layer name.

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.