Workspace To Raster Dataset (Data Management)
Summary
Mosaics all the raster datasets stored within the specified workspace into one raster dataset.
Usage
-
The target raster dataset must already exist for the tool to run.
-
If a target raster dataset does not already exist, use the Create Raster Dataset tool to create a new raster dataset.
-
Since mosaicking will take place, you will need to specify the mosaic method and colormap mode to use.
-
If the target raster dataset is an empty raster dataset, the cell size and spatial reference of the first input raster dataset will be applied to the mosaic.
-
Whenever possible, use the Last Mosaic Operator to mosaic raster datasets to an existing raster dataset in a file geodatabase or ArcSDE geodatabase; it is by far the most effective way to mosaic.
-
For mosaicking of discrete data, First, Minimum, or Maximum Mosaic Operator options will provide the most meaningful results. The Blend and Mean Mosaic Operator options are best suited for continuous data.
-
The color matching method drop-down arrow allows you to choose an algorithm to color match the datasets in your mosaic.
-
For file-based rasters and personal geodatabase rasters, the Ignore Background Value must be set to the same value as NoData in order for the background value to be ignored. File geodatabase rasters and ArcSDE rasters will work without this extra step.
-
For floating-point input raster datasets of different resolutions or when cells are not aligned, it is recommended to resample all the data using bilinear interpolation or cubic convolution before running Mosaic; otherwise, Mosaic will automatically resample the raster datasets using nearest neighbor resampling, which is not appropriate for continuous data types.
Syntax
Parameter | Explanation | Data Type |
in_workspace |
The workspace that contains all the raster datasets to be mosaicked into the raster dataset. | Workspace |
in_raster_dataset |
The raster dataset that will have all the rasters from the workspace mosaicked into it. The raster dataset must already exist. | Raster Dataset |
include_subdirectories (Optional) |
Specify whether to include subdirectories.
| Boolean |
mosaic_type (Optional) |
The method used to mosaic overlapping areas.
For more information about each mosaic operator, refer to Mosaic Operator. | String |
colormap (Optional) |
The method used to choose which color map from the input rasters will be applied to the mosaic output.
For more information about each colormap mode, refer to Mosaic colormap mode. | String |
background_value (Optional) |
Use this option to remove the unwanted values created around the raster data. The value specified will be distinguished from other valuable data in the raster dataset. For example, a value of zero along the raster dataset's borders will be distinguished from zero values within the raster dataset. The pixel value specified will be set to NoData in the output raster dataset. For file-based rasters and personal geodatabase rasters, the Ignore Background Value must be set to the same value as NoData in order for the background value to be ignored. ArcSDE and file geodatabase rasters will work without this extra step. | Double |
nodata_value (Optional) |
All the pixels with the specified value will be set to NoData in the output raster dataset. | Double |
onebit_to_eightbit (Optional) |
Choose whether the input 1-bit raster dataset will be converted to an 8-bit raster dataset. In this conversion the value 1 in the input raster dataset will be changed to 255 in the output raster dataset. This is useful when importing a 1-bit raster dataset to ArcSDE. One-bit raster datasets have 8-bit pyramid layers when stored in a file system, but in ArcSDE, 1-bit raster datasets can only have 1-bit pyramid layers, which makes the display unpleasant. By converting the data to 8 bit in ArcSDE, the pyramid layers are built as 8 bit instead of 1 bit, resulting in a proper raster dataset in the display.
| Boolean |
mosaicking_tolerance (Optional) |
When mosaicking takes place, the target and the source pixels do not always line up exactly. When there is a misalignment of pixels, a decision needs to be made whether resampling takes place or whether the data should be shifted. The mosaicking tolerance controls whether resampling of the pixels take place or if the pixels should be shifted. If the difference in pixel alignment (of the incoming dataset and the target dataset) is greater than the tolerance, resampling will take place. If the difference in pixel alignment (of the incoming dataset and the target dataset) is less than the tolerance, resampling will not take place (instead, a shift is performed). The unit of tolerance is a pixel, where the valid value range is 0 to 0.5. A tolerance of 0.5 will guarantee a shift takes place. A tolerance of zero guarantees resampling, if there is a misalignment in pixels. For example, the source and target pixels have a misalignment of 0.25. If the mosaicking tolerance is set to 0.2, then resampling will take place since the pixel misalignment is greater than the tolerance. If the mosaicking tolerance is set to 0.3, then the pixels will be shifted. | Double |
MatchingMethod (Optional) |
Choose the color matching method to apply to the rasters.
| String |
colormap_to_RGB (Optional) |
If the input raster dataset has a color map, the output raster dataset can be converted to a three-band output raster dataset. This is useful when mosaicking rasters with different color maps.
| Boolean |
Code Sample
This is a Python sample for the WorkspaceToRasterDataset tool.
import arcpy
arcpy.WorkspaceToRasterDataset_management("c:/data/WS2RD", "c:/fgdb.gdb/outdats",
"INCLUDE_SUBDIRECTORIES", "LAST",
"FIRST", "0", "9", "", "",
"HISTOGRAM_MATCHING", "")
This is a Python script sample for the WorkspaceToRasterDataset tool.
##==================================
##Workspace To Raster Dataset
##Usage: WorkspaceToRasterDataset_management in_workspace in_raster_dataset {NONE | INCLUDE_SUBDIRECTORIES}
## {LAST | FIRST | BLEND | MEAN | MINIMUM | MAXIMUM} {FIRST | REJECT
## | LAST | MATCH} {background_value} {nodata_value} {NONE | OneBitTo8Bit}
## {mosaicking_tolerance} {NONE | STATISTIC_MATCHING | HISTOGRAM_MATCHING
## | LINEARCORRELATION_MATCHING} {NONE | ColormapToRGB}
try:
import arcpy
arcpy.env.workspace = r"\\MyMachine\PrjWorkspace\RasGP"
##Mosaic images to File Geodatabase Raster Dataset with Background and Nodata setting and Color Correction
arcpy.WorkspaceToRasterDataset_management("WS2RD", "fgdb.gdb\\dataset", "INCLUDE_SUBDIRECTORIES", "LAST", \
"FIRST", "0", "9", "", "", "HISTOGRAM_MATCHING", "")
##Mosaic Colormap image to RGB image
arcpy.WorkspaceToRasterDataset_management("WS2RD_clr","fgdb.gdb\\dataset2", "INCLUDE_SUBDIRECTORIES", "LAST",\
"FIRST", "", "", "", "0.3", "", "ColormapToRGB")
except:
print "Workspace To Raster Dataset example failed."
print arcpy.GetMessages()