I have a large number of airphotos giving coverage of an area going back decades. - someone may have a smoother means to accomplish my goal here. I'm weak in Python sadly. I'm attempting to shrink/trim/eliminate a given number of pixels along the edges of the .TIF airphotos that I have.

The photos are quite old and scanned from negatives, and have black borders from the scanning of the film negatives, so I can't set nodata=0,0,0 as the border isn't a perfect 0,0,0 (in some cases water features are closer to 0,0,0 that then border is)

There's too many images to sensibly do this individually. I'll walk through my thoughts/plan below. My end goal is to use Build Footprints 'Shrink Distance' Feature:

  1. Use recursive iteration to go through every .geotiff airphoto within the "airphotos" folder.
  2. Create a file geodatabase where the name of the .gdb matches the raster
  3. Create a Mosaic Dataset within that File Geodatabase [Mosaicmb]. The tools run as hoped up to this point, i've been able to create all the geodatabases.
  4. Here the problems start: Add the raster that is being iterated to the newly created empty mosaic dataset. Fails with the error listed below
  5. Build Footprints, and use the shrink feature to eliminate my borders, by cutting say 50 pixels off all sides of each photo.

ArcGIS reports that mosaicmb doesn't exist - which it obviously doesn't, and it won't exist until the tool runs.

If you know a slick way to trim border pixels, that will help too.

Error 000732 - Mosaic Dataset: Dataset Q:\.......\test5\%name%.gdb\mosaicmb does not exist or is not supported


I'm still experimenting and trying what works, but at this point I'm shooting in the dark and praying. I'll update if I have a breakthrough.

  • Why are you creating a File gdb for each raster? My guess is that you don't need to create all those gdb, but only add the rasters to one.
    – Stefan
    Commented Jan 27, 2016 at 11:03
  • Do you mean create a single file gdb and then create the mosaics within that single file gdb? That would work, the only issue is that the "Create Mosaic Dataset" tool won't allow me to use "%name%" for some reason, as soon as I type "%name%" it reverts to "T_name_"
    – ktopo
    Commented Jan 27, 2016 at 20:32
  • Your routine is wrong. You're iteraring the raster files and for each raster you're creating a gdb. So thats why you cannot use %name%. You need to make a gdb on forehand and use that as input.
    – Stefan
    Commented Jan 28, 2016 at 10:03
  • Thank you so much Stefan, you put me on the right track and it worked perfectly. I'm just cleaning up the modelbuilder screen, but I'll post what worked shortly for anyone who may find themselves here in the future.
    – ktopo
    Commented Jan 28, 2016 at 16:01

2 Answers 2


You might attempt to set a "precondition" by linking the mosaicmb variable to the Add Raster To Mosaic Dataset a second time, and choosing "precondition" when the connect tool of ModelBuilder shows it's context menu.

A pre-condition will ensure the File Geodatabase and Mosaic Dataset will be created in advance of the Add Raster To Mosaic Dataset being run.

See the ArcGIS Help: http://desktop.arcgis.com/en/desktop/latest/analyze/modelbuilder/a-quick-tour-of-using-precondition.htm


Stefan's comments helped. I'll explain below in case this is helpful to others in the future.

Here's the ModelBuilder image for what worked for me in the end. Model Created a single file gdb filled with the single image mosaics and trimmed the outer pixels for every one.

  • Created the File Geodatabase manually prior to setting up the model
  • Iterate Rasters is set recursive so scans all files and subfolders within the AirPhotos folder for my .TIF airphotos.
  • For Each Raster, Parse Path stores filename without extension (NAME) as "Value"
  • Create Mosaic Dataset uses that manually created file gdb, Preconditions are set. It names the file whatever "Value" is stored as for the iteration
  • Adds the raster that iterate is on to the mosaic dataset
  • Build Footprints is being used for "Shrink Distance" feature, and trims X pixels from the image

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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