I have around 200 Geo-referenced JP2 files that I want to add to ArcMap. Out of these I want to create a single Mosaic raster.

However, I'm having issues adding the data.

Everything is fine for the first 100 files or so, after that, whenever I want to add more, it just stalls. I've managed to add around 150 files, but now, the add data button doesn't show the connected folders. The folders were working before, since I did managed to add 150 files.

Any ideas around this, it just looks as if ArcMap can't deal with that many raster images in bulk.

I use ArcGIS Desktop 10.3.1

  • 1
    It is possible to run the Mosaic tool on files that are not yet added to ArcGIS. You can simply browse to the directory and select the desired files. This would potentially avoid the problem entirely. You may also avoid performance issues caused by trying to render 200 rasters being loaded into ArcGIS all at once. Oct 30 '15 at 0:11
  • Do you use filesystem or gdb? Filesystem has a size limit of 2GB. Maybe that's the reason.
    – Celik A
    Oct 30 '15 at 8:14
  • One other option if you are working in the ArcGIS sphere, and simply need to do this for viewing purposes, is to create a Raster Catalog. These are pretty well optimized in that you only load a single object into ArcMap, and the Raster Catalog handles which rasters to load in based on spatial location. An unmanaged RC simply acts as a pointer to existing rasters, so no need to import them anywhere. Oct 30 '15 at 21:43

To create mosaic dataset and load your rasters into it, you don't need to add the rasters to the map. @Paulo Raposo is giving you a python solution, however you can do this without python. simply create a mosaic dataset inside a file geodatabase with ArcCatalog and then right-click it and choose "Add Rasters..."

Then browse to the rasters folder and add them to the GP tool.

you will end up with a mosaic dataset with all rasters embedded into it.


I think it's a memory issue, and that ArcMap can't deal with that many rasters loaded all at once. As suggested by @Get-Spatial, you can run the Mosaic tool on files on your computer that aren't loaded into ArcMap. Here's a quick Python script that automates doing this mosaic operation one file at a time - a little slow, perhaps, but shouldn't overload memory.

import os
from os import listdir
from os.path import isfile, join
import arcpy

# List all the files to mosaic together - assumes these are all
# the files in the given directory.
mypath = r"C:\path\to\directory\containing\files" # edit as necessary
myfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]

# Get info about the first file in order to make a target raster
# to mosaic others into - assumes they all have the same pixel
# size and spatial reference
cellsizex = arcpy.GetRasterProperties_management(join(mypath, myfiles[0]), "CELLSIZEX")
valuetype = arcpy.GetRasterProperties_management(join(mypath, myfiles[0]), "VALUETYPE")
cellsize = cellsizex.getOutput(0) # assumes cells are equal in x and y size
pixltype = valuetype.getOutput(0)
desc = arcpy.Describe(join(mypath, myfiles[0]))
spatialRef = desc.spatialReference

# Define pixel types for the coming Create Raster Dataset tool,
# see http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000096000000
pixelTypeDictionary = {}
pixelTypeDictionary["0"] = "1_BIT"
pixelTypeDictionary["1"] = "2_BIT"
pixelTypeDictionary["2"] = "4_BIT"
pixelTypeDictionary["3"] = "8_BIT_UNSIGNED"
pixelTypeDictionary["4"] = "8_BIT_SIGNED"
pixelTypeDictionary["5"] = "16_BIT_UNSIGNED"
pixelTypeDictionary["6"] = "16_BIT_SIGNED"
pixelTypeDictionary["7"] = "32_BIT_UNSIGNED"
pixelTypeDictionary["8"] = "32_BIT_SIGNED"
pixelTypeDictionary["9"] = "32_BIT_FLOAT"
pixelTypeDictionary["10"] = "64_BIT"
# this leaves out:    
# 11 = 8_bit complex
# 12 = 16_bit complex
# 13 = 32-bit complex
# 14 = 64-bit complex

# Create a destination raster to mosaic the others into
# using the info we gathered above
out_name = "mosaic.tif" # GeoTiff, can be other formats.
arcpy.CreateRasterDataset_management(mypath, out_name, cellsize,
                                     pixelTypeDictionary[pixltype], spatialRef)

# Now iteratively merge each of the rasters into the one we
# created for this purpose. This function can take more than
# one input at a time, but since we may have memory limitations
# with many, we'll do it one by one.
target = os.path.join(mypath, out_name)
for infile in myfiles:
    infilewithpath = join(mypath, infile)
    # Note there are many optional parameters left out here:
    arcpy.Mosaic_management([infilewithpath], target)
  • Hi, thanks a lot for the answer. I'm running into a weird error in the "cellsizex.getOutput()" line, where it says it has an error parsing the arguments. "AttributeError: ResultObject: Error in parsing arguments GetOutput" Any idea why that might be. I also would edit the myfiles[0] to join(mypath, myfiles[0]) in the cellsizex lines Nov 2 '15 at 17:26
  • Thanks Leon - I got the same error. I had forgotten the index number argument for .getOuput(). Fixed above, along with a few other little things. This script worked for me just now on two dummy input rasters. Nov 3 '15 at 2:10

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.